[英]The to add the main project jar in the project root folder
Apache Maven 3.3.3
OS name: "windows 7"
I have the main class in my mvn project in: 我的mvn项目中有主班:
src/main/java/rev/App.java
App.java is the default maven main "Hello World!"
App.java是默认的Maven主程序
"Hello World!"
I then put the dependencies in a lib folder in the root directory ( assembly.xml below ): 然后,我将依赖项放在根目录( 下面的assembly.xml )的lib文件夹中:
..... .....
However, after doing this, the project's main jar doesn't appear anywhere in the folder. 但是,执行此操作后,项目的主jar不会出现在文件夹中的任何位置。 How can I get the main jar to appear in the root folder allongside the lib folder?
如何使主jar出现在lib文件夹旁边的根文件夹中?
pom.xml: pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rev</groupId>
<artifactId>rev</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>rev</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
assembly.xml: assembly.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>bin</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>${project.basedir}/src/main/config/config.properties</source>
<filtered>true</filtered>
</file>
</files>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/scripts</directory>
<outputDirectory>scripts</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveDependencies>false</useTransitiveDependencies>
<unpack>false</unpack>
<includes>
<include>*:*:jar</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
You need to add the built project jar explicitly in your assembly configuration. 您需要在程序集配置中显式添加构建的项目jar。
<files>
<file>
<source>${project.basedir}/target/${project.build.finalName}.jar</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.