2014-10-06 59 views
0

我想使用Maven创建一个jar,其中包含特定的相关工件并排除某些源java文件。使用依赖关系创建jar并排除特定源文件

目前我使用这个片段:

  <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-shade-plugin</artifactId> 
      <executions> 
       <execution> 
         <id>shadedJar</id> 
         <phase>package</phase> 
         <goals> 
          <goal>shade</goal> 
         </goals> 
         <configuration> 
          <shadedClassifierName>classifier</shadedClassifierName> 
          <shadedArtifactAttached>true</shadedArtifactAttached> 
          <createDependencyReducedPom>false</createDependencyReducedPom> 
          <artifactSet> 
           <includes> 
            <include>com.google.guava:guava</include> 
           </includes> 
          </artifactSet> 
         </configuration> 
        </execution> 
      </executions> 

因此,罐子不包含“番石榴”人造文件,但是我也想排除某些源文件(例如在src /主要的特定文件/java/my.package/),我该怎么做?

+0

究竟是什么源文件? – Mardoz 2014-10-06 08:48:08

+0

我想排除位于模块源文件的/src/main/java/my.package文件夹下的一些特定文件。 – opeled 2014-10-06 08:51:55

回答

0

我使用阴影来创建一个jar,但我不需要一些eclipse,txt和其他与开发相关的东西的文件。

这是我的代码,也许你可以添加它并使用它。

  <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-shade-plugin</artifactId> 
       <version>2.2</version> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>shade</goal> 
         </goals> 
         <configuration> 
          <createDependencyReducedPom>false</createDependencyReducedPom> 
          <filters> 
           <filter> 
            <artifact>*:*</artifact> 
            <excludes> 
             <exclude>META-INF/*.SF</exclude> 
             <exclude>META-INF/*.DSA</exclude> 
             <exclude>META-INF/*.RSA</exclude> 
             <exclude>.settings/**</exclude> 
             <exclude>*.classpath</exclude> 
             <exclude>*.project</exclude> 
             <exclude>*.txt</exclude> 
            </excludes> 
           </filter> 
          </filters> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
+0

太好了,帮助 – opeled 2014-10-06 12:51:44

+0

@opeled如果你可以用我的通用答案解决你的问题,将帖子标记为正确的答案,并且票证将完成 – 2014-10-06 13:27:09