2

I followed the post install jar built from ant task into local maven repository

I cannot figure out what is the problem, but this simply does not work. I do not know why they used <arg value="mvn.bat"/> instead of <arg value="mvn "/> Anyway I have the following xml file:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <configuration>  
         <target name="mvn">
          <property environment="env" />
          <property name="appname" value="hellojavaworld" />
           <exec dir="." executable="cmd">
             <arg value="/c"/>
             <arg value="mvn "/>
             <arg value="install:install-file"/>
             <arg value="-Dfile=c:\Documents and Settings\bbb\workspace\HelloServlet\hellojavaworld\src\main\java\hellojavaworld.bin\hellojavaworld.jar"/>
             <arg value ="-DgroupId=${appname}"/>
             <arg value="-DartifactId=${appname}"/>
             <arg value="-Dversion=1.0"/>
             <arg value="-Dpackaging=jar"/>
             <arg value="-DgeneratePOM=true"/>  
           </exec>
         </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
    </plugins>
</build>

It returns errors:

Error resolving version for plugin ' install:install-file -D file=c' from the repositories [local (C:\Documents and Settings\bbb.m2\repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository

Community
  • 1
  • 1
Michal
  • 610
  • 10
  • 24
  • I think that problem is that -Dfile contains blanks on path and question is how to overcome it? – Michal Oct 20 '15 at 10:25
  • It seems that script above is correct,but the path is not properly recognized due to blanks. I tried to specify -Dfile path without blanks and has worked. – Michal Oct 20 '15 at 10:30
  • @Tunaki You are the man. Your solution works! I do not know what is the problem if there is a blank after mvn. Is there any possibility to display how the process is handled? I mean how it is translated and interpreted. The maven switch -X does not say so much information. – Michal Oct 20 '15 at 11:55
  • I added this as an answer since my guess was correct. Feel free to [accept](http://meta.stackexchange.com/q/5234) it. – Tunaki Oct 20 '15 at 12:07

1 Answers1

2

Your problem is very subtle and the error message doesn't help in this case.

The problem comes from the following configuration of the maven-antrun-plugin:

<arg value="mvn "/>

It should be

<arg value="mvn"/>

The space at the end gets encoded to %20 and this messes things up. I noticed it because when running your configuration, I saw the following log:

[exec] Downloading: https://repo.maven.apache.org/maven2/%20install/install-file%20-Dfile=c/maven-metadata.xml

Note that in this log, Maven is trying to look for install-file%20 plugin, which obviously doesn't work.

Tunaki
  • 132,869
  • 46
  • 340
  • 423