How to combine two Jar files

后端 未结 8 1427
情深已故
情深已故 2020-11-28 05:31

Is it possible to combine two jar files such that in an applet tag I can simply do something like

archive=\"jarjar.jar/jar1.jar\"...  ...archive=\"jarjar.jar         


        
相关标签:
8条回答
  • 2020-11-28 06:20

    If you are using gradle, just add the following to build.gradle. No plugins required. If you need special options, then go with Fatjar plugin, as initialZero suggests.

    task superSimpleJar(type: Jar) {
        baseName = project.name + '-all'
        from { configurations.compile.collect { it.isDirectory() ? it :     zipTree(it) } }
        with jar
    }
    

    For Android project, add this to app/build.gradle and run "gradlew superSimpleJar". Find jar in build/libs/app-all.jar

    task superSimpleJar(type: Jar) {
    baseName = project.name + '-all'
    from {
    
        configurations.compile.findAll {
    
        it.getName() != 'android.jar'
    
        }.collect {
    
        it.isDirectory() ? it : zipTree(it)
    
        }
     }
    }
    
    0 讨论(0)
  • 2020-11-28 06:23

    Just unzip both jar files, then zip the results into one zip file, and rename this to jar again.

    But as adarshr said: Better use the jar command for that.

    0 讨论(0)
提交回复
热议问题