当前位置: 首页 > 工具软件 > Jar Compiler > 使用案例 >

maven jar

祁永嘉
2023-12-01
  • jar:jar create a jar file for your project sources.
  • jar:test-jar create a jar file for your project test classes.

 

maven-jar-plugin

 

 

How to create a jar containing test classes

When you want to create a jar containing test-classes, you would probably want to reuse those classes. There are two ways to solve this:

  • Create an attached jar with the test-classes from the current project and loose its transitive test-scoped dependencies.
  • Create a separate project with the test-classes.

 

Maven Shade Plugin

 Maven Assembly plugin 

 

 

 <build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
    <configuration>
     <configuration>
      <includes>
       <include>**pom*</include>
      </includes>
     </configuration>
    </configuration>

   </plugin>
   <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
    <configuration>
       <descriptors>
      <descriptor>src/main/resources/assemblies/assembly.xml</descriptor>
     </descriptors>
    </configuration>
   </plugin>
  </plugins>

 </build>

 

 

 

<assembly  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.0http://maven.apache.org/xsd/assembly-1.0.0.xsd">
     <id>package</id>
     <formats>
         <format>zip</format>
     </formats>
     <includeBaseDirectory>false</includeBaseDirectory>
     <fileSets>
         <fileSet>
             <directory>target</directory>
             <outputDirectory>/target</outputDirectory>
         </fileSet>
         <fileSet>
          <includes><include>pom.xml</include></includes>
         </fileSet>
      </fileSets>
 </assembly>

 

 

[INFO] >>> maven-assembly-plugin:2.4:assembly (default-cli) @ w >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ w ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ w ---
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\w\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ w ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ w ---
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 2 source files to C:\w\target\test-classes
[INFO]

 

 

 

 clean  test-compile assembly:single

 类似资料:

相关阅读

相关文章

相关问答