2015-11-20 89 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> 
相關問題