Maven自定义Manifest (META-INF/MANIFEST.MF)

 1,打包时添加一些常用信息到META-INF/MANIFEST.MF(添加Class-Path信息,设置主类MainClass)

  
    UTF-8
    yyyy-MM-dd_HH_mm
  

  
    
      
        org.apache.maven.plugins
        maven-jar-plugin
        
          
            true
            
              true
              fully.qualified.MainClass
              true
              true
            
            
              ${project.url}
              ${maven.build.timestamp}
            
          
        
      
    
  

 结果:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: jervalj
Build-Jdk: 1.6.0_34
Specification-Title: maven-test
Specification-Version: 1.0-SNAPSHOT
Implementation-Title: maven-test
Implementation-Version: 1.0-SNAPSHOT
Implementation-Vendor-Id: sdf
build-time: 2014-01-03_17_12
url: http://maven.apache.org
Class-Path: persistence-rds-1.9-SNAPSHOT.jar persistence-common-1.5.5-
 SNAPSHOT.jar commons-lang-2.1.jar

 

2,修改Class-Path信息(修改Class-Path前缀,自定义Class-Path格式)


        org.apache.maven.plugins
        maven-jar-plugin
        2.4
        
          
            true
            
              true
              true
              true
              lib/
              custom
              WEB-INF/lib/$${artifact.groupIdPath}/$${artifact.artifactId}-$${artifact.version}$${dashClassifier?}.$${artifact.extension}
            
            
              ${project.url}
              ${maven.build.timestamp}
            
          
        
      

 结果:

Manifest-Version: 1.0
build-time: 2014-01-03_17_36
Implementation-Title: maven-test
Implementation-Version: 1.0-SNAPSHOT
Class-Path: lib/WEB-INF/lib/com/xxx/persistence/persistence-rds-1.9
 -SNAPSHOT.jar lib/WEB-INF/lib/com/xxx/persistence/persistence-comm
 on-1.5.5-20130402.064609-5.jar lib/WEB-INF/lib/com/xxx/arch/tools/
 xxx-arch-aop-1.1.jar lib/WEB-INF/lib/aspectwerkz/aspectwerkz-2.0.j
 ar lib/WEB-INF/lib/com/jcraft/jsch-0.1.27.jar lib/WEB-INF/lib/org/jbo
 ss/jboss-eap/server/production/lib/servlet-api-JB_4.3.0.GA_CP06.jar l
 ib/WEB-INF/lib/com/xxx/tools/xxx-report-bin-1.21.jar lib/WEB-IN
 F/lib/commons-lang/commons-lang-2.1.jar
Built-By: jervalj
Created-By: Apache Maven
url: http://maven.apache.org
Implementation-Vendor-Id: sdf
Build-Jdk: 1.6.0_34
Specification-Title: maven-test
Specification-Version: 1.0-SNAPSHOT
Archiver-Version: Plexus Archiver

 

3,去掉Class-Path版本信息

      
        org.apache.maven.plugins
        maven-jar-plugin
        2.4
        
          
            true
            
              true
              true
              true
              custom
              $${artifact.artifactId}.$${artifact.extension}
            
            
              ${project.url}
              ${maven.build.timestamp}
            
          
        
      

 结果:

Manifest-Version: 1.0
build-time: 2014-01-03_17_44
Implementation-Title: maven-test
Implementation-Version: 1.0-SNAPSHOT
Class-Path: persistence-rds.jar persistence-common.jar xxx-arch-aop
 .jar aspectwerkz.jar jsch.jar servlet-api.jar xxx-report-bin.jar c
 ommons-lang.jar
Built-By: jervalj
Created-By: Apache Maven
url: http://maven.apache.org
Implementation-Vendor-Id: sdf
Build-Jdk: 1.6.0_34
Specification-Title: maven-test
Specification-Version: 1.0-SNAPSHOT
Archiver-Version: Plexus Archiver

 

 4,使用已存在的META-INF/MANIFEST.MF文件.


        org.apache.maven.plugins
        maven-jar-plugin
        
          
            src/main/resources/META-INF/MANIFEST.MF
          
        
      

 

 

 

你可能感兴趣的:(Maven)