我在Idea中有一个带有两个模块的maven项目:1)web和2)web-start-swt-jar。
web-start-swt-jar pom.xml配置为包含依赖项。
我的项目如下:
[root]
- web-start-swt-jar pom.xml (packaging jar)
- web pom.xml (packaging war)
pom.xml (packaging pom)
是否有可能制定我想要的步骤:
是的我使用maven assemply插件,但它复制了没有依赖项的jar文件。
谢谢!
P.S。您可能建议使用一些插件来安装web-start工作吗?例如webstart-maven-plugin?请帮忙。
答案 0 :(得分:1)
[root]
- web-start-swt-jar pom.xml (packaging jar)
- web pom.xml (packaging war)
pom.xml (packaging pom)
尝试添加:web pom.xml
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>web-start-swt-jar</artifactId>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>web-start-swt-jar</artifactId>
<type>jar</type>
<overWrite>false</overWrite>
<!-- outputDirectory not sure. to test-->
<outputDirectory>${basedir}/src/main/webapp/webstartFolder</outputDirectory>
<destFileName>web-start-swt-jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
答案 1 :(得分:0)
似乎找到了答案:使用maven-shade-plugin
打包带有dependensies的jar和maven-dependency-plugin
来复制到prepare-package
阶段的自定义文件夹。
别忘了通过<dependency managament>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>my.group</groupId>
<artifactId>webstart-swt-jar</artifactId>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>
${project.build.directory}/${project.build.finalName}/SomeFolderHere
</outputDirectory>
<destFileName>(optional rename..)webstart-swt-jar.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<强>增加:强>
但是,如果我没有将webstart-swt-jar
设置为依赖项,则构建失败并显示错误“webstart-swt-jar not found”。它不好,因为工件在WEB-INF \ lib和我的\ custom文件夹中重复...