Simpliest way to add an attribute to a jar Manifest in Maven

后端 未结 5 1471
时光说笑
时光说笑 2020-12-06 06:06

Since the last Java update, I need to tag my applet jars manifest with the Trusted-Library attribute to avoid warning popup when javascript is communicating wit

5条回答
  •  -上瘾入骨i
    2020-12-06 06:33

    You can do that with the Maven JAR Plugin during the creation of the JAR file. Add the following to your pom.xml:

    
        org.apache.maven.plugins
        maven-jar-plugin
        
            
                false
                
                    true
                
            
        
    
    
        org.apache.maven.plugins
        maven-jarsigner-plugin
        1.2
        
            
                sign
                
                    sign
                
            
        
        
            /path/to/testkeystore
            myalias
            test123
        
    
    

    The main attributes as specified in the JAR File Specification are available as dedicated elements, e.g.:

    
        org.apache.maven.plugins
        maven-jar-plugin
        
            
                false
                
                    true
                    true
                
                
                    true
                
            
        
    
    

    See the Maven Archiver Reference for further information.

    To modify the manifest inside an existing jar file create a text file, e.g. mymanifest.mf which contains the required properties:

    Trusted-Library: true
    

    You can add the attributes of this file to an existing jar by executing the following command:

    jar -cfm file-to-be-modified.jar mymanifest.mf
    

    This will modify the manifest.mf inside the given jar.

提交回复
热议问题