In my Ant script, i'm using the Maven Ant tasks to install an artifact to the local repository, like this:
<target name="installProject">
<artifact:pom id="mypom" file="${user.dir}/pom.xml" />
<artifact:install file="target/myproject-1.0.jar">
<pom refid="mypom"/>
</artifact:install>
</target>
What i don't like about this approach is that i have to define the name of the Jar I want to install explicitely: target/myproject-1.0.jar
But what if the name of that Jar changes? I want to have a more generic approach. How can i let Maven Ant Tasks install all artifacts that Maven would also install when running mvn clean install
in the same dir on commandline (where I DON'T have to provide which Jar i want to install)?
(yes, i could also just call Maven with <exec executable="mvn" ...>
, but I think it's cleaner to use Maven Ant Tasks for this)
Nobody knows what your build.xml produces so you need to pass desired artifact names to ant. It can be done through project.groupId, project.artifactId, project.version properties that should be available in your antrun element. Then after you build.xml worked. You can use attachartifact ant task to attach your artifacts to maven. I.E.
<attachartifact file="${project.build.directory}/${project.artifactId}-${project.version}.jar" type="jar"/>
After that when you performing maven install
it install your ant artifacts.