2015-11-20 87 views
0
Apache Maven 3.3.3 
OS name: "windows 7" 

我的主类在我MVN项目:的增加主要项目JAR在项目的根文件夹

src/main/java/rev/App.java 

App.java是默认的Maven主要"Hello World!"

我然后将依赖项放在根目录下的一个lib文件夹中(assembly.xml下面的):

.....

但是,执行此操作后,项目的主jar不会出现在文件夹中的任何位置。如何让主jar出现在lib文件夹的allongside根目录下?

的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 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> 

回答

1

你需要明确添加内置项目JAR在你的组件的构造。

<files> 
    <file> 
     <source>${project.basedir}/target/${project.build.finalName}.jar</source> 
     <outputDirectory>/</outputDirectory> 
    </file> 
</files> 
相关问题