在我的 Ant 脚本中,我使用 Maven Ant 任务将工件安装到本地存储库,如下所示:
<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>
我不喜欢这种方法的是我必须明确定义要安装的 Jar 的名称: target/myproject-1.0.jar
但是如果该 Jar 的名称发生变化怎么办?我想要一种更通用的方法。如何让 Maven Ant 任务安装 Maven 在命令行上的同一目录中运行 mvn clean install 时也会安装的所有工件(我不必提供我想要安装的 Jar)?
(是的,我也可以使用
调用 Maven,但我认为使用 Maven Ant Tasks 更干净)
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)
发布评论
评论(1)
没有人知道您的 build.xml 会生成什么,因此您需要将所需的工件名称传递给 ant。可以通过 antrun 元素中可用的 project.groupId、project.artifactId、project.version 属性来完成。
然后在 build.xml 工作后。您可以使用 Attachartifact ant 任务将工件附加到 Maven。 IE
之后,当您执行
maven install
时,它会安装您的 ant 工件。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.
After that when you performing
maven install
it install your ant artifacts.