0

I have spent 3 days trying to see why this error is produced when executing the jar. Finally, I opened the jar file and noticed that the META-INF folder contains the MANIFEST.MF file but also some folders and some other files too. If I delete all the files except the MANIFEST.MF file (the folders are not deleted) then the error disappears and I can execute the jar.

The build.gradle file I have used is:

    plugins {
        // Apply the java-library plugin for API and implementation separation.
        id 'java-library'
        id 'java'
        id 'application'
        id 'eclipse' // for avoiding 'java.smartcardio' complain @see:https://stackoverflow.com/a/75222235/7704658
    }


    // This code is for avoiding 'java.smartcardio' complain in Eclipse @see: https://stackoverflow.com/a/75222235/7704658
    eclipse {
        classpath {
            file {
                whenMerged {
                    def jre = entries.find { it.path.contains 'org.eclipse.jdt.launching.JRE_CONTAINER' }
                    jre.entryAttributes['module'] = 'true'
                    jre.entryAttributes['limit-modules'] = 'java.se,jdk.accessibility,jdk.dynalink,jdk.httpserver,jdk.jartool,jdk.javadoc,jdk.jconsole,jdk.jshell,jdk.jsobject,jdk.management.jfr,jdk.net,jdk.nio.mapmode,jdk.sctp,jdk.security.auth,jdk.security.jgss,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom,java.smartcardio'
                    jre.entryAttributes['add-modules'] = 'java.smartcardio'           //--limit-modules java.se --add-modules java.smartcardio
                }
            }
        }
    }


    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" } //@see: https://stackoverflow.com/questions/38905939/how-to-import-library-from-jitpack-io-using-gradle
        flatDir {dirs "$rootDir/../mynewtargets2"} //@see https://stackoverflow.com/a/25966303
    }

    // My customization 
    project.jar.destinationDirectory = file("$rootDir/../mynewtargets2")   
    project.archivesBaseName = 'd05-autofirma-simple'
    project.version = '4.0'


    dependencies {
        api libs.pdfbox
        /** other apis stuff go here.........*/
    }

    distTar {
        duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    }

    distZip {
        duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    }   

    application {
        mainClass = 'es.gob.afirma.standalone.SimpleAfirma'
    }

    jar {
        zip64=true
        duplicatesStrategy = DuplicatesStrategy.EXCLUDE
        manifest {
            attributes(
                'Main-Class': 'es.gob.afirma.standalone.SimpleAfirma',
            ) 
        }
        archiveClassifier = "all"
    
        from {
           sourceSets.main.allSource  //Include java sources
           configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } 
        }
    }

Can anybody explain why the MANIFEST.MF cannot share the META-INF folder with any other file?

Thanks

Ximo Dante
  • 67
  • 9

0 Answers0