英文:
How to use Maven to create directories then copy jars and dependencies into those directories
问题
我正在将一个Java项目从任何构建过程转换为Maven。
目前,Maven可以编译该项目的JAR文件,但要完全替代Ant,我需要执行两个额外的步骤:
- 创建一个文件树
- 将项目中存储的编译后的JAR文件和其他文件复制到步骤1中创建的目录中。
这个树需要反映出JAR文件和资源文件将出现在安装在机器上的目录结构。
例如,srs/foo/bar/scripts
目录中的内容可能需要移动到 /usr/local/myFoo/spam/bar/scripts
,
而JAR文件可能需要从 ./myPjroject/target/*.jar
移动到 /usr/local/tomcat/webaps/fooApp/WEB-INF/lib
,
等等。
这个树然后不会被压缩,而是由后续的程序处理。
我已经阅读到安装插件(install mojo)可以复制JAR文件,但我没有看到任何文档表明它也可以复制我需要移动的其他文件。
英文:
I am converting a Java project from an any build process to Maven.
Maven can currently compile the jars from the project but to fully replace Ant I need to do two additional steps:
- Create a file tree
- Copy the compiled jars and other files stored in the project into desired directories created in step 1.
This tree needs to mirror the structure that both jars and resource files will appear in installed machine.
e.g. the contents of srs/foo/bar/scripts
might need to be moved to /usr/local/myFoo/spam/bar/scripts
while jars might need to
go from ./myPjroject/target/*.jar
to /usr/local/tomcat/webaps/fooApp/WEB-IBF/lib
ect
this tree does not then get zipped but processed by a subsequent program.
I have read that that install mojo can copy the jars but I have not seen any documentation showing that it can also copy the other files I need to move.
答案1
得分: 1
以下是翻译好的部分:
"I'm not sure about your question but if you only want to copy files creating target directories on the fly you can use the maven-antrun-plugin.
Something like
Is this what you are looking for?"
英文:
I'm not sure about your question but if you only want to copy files creating target directories on the fly you can use the maven-antrun-plugin.
Something like
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copywar</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="copy war into install folder">
<copy
file="target/my.war"
tofile="/install/my/${maven.build.timestamp}/my.war" />
</target>
</configuration>
</execution>
</executions>
</plugin>
Is this what you are looking for?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论