Gradle JAR - do not export package

I am creating a jar file using gradle which contains one class file. However, when I go to use my jar file, I get:

failed to resolve pvx.core.util.DesEncrypter class

in the import statement (executed from the command line or in eclipse). If I create a jar file for the class from the command line, everything is fine. The only difference that I could find between the two jar files was that from the command line it has MANIFEST.MF with permissions of 755, and the generated gradle has permissions of 644.

task utilJar (dependsOn:classes, type: Jar) {
    archiveName "DesEncrypter-${version}.jar"
    manifest { attributes "Created-By": "1.8.0_60 (Oracle Corporation)" }
    into ('.') {
        from "$buildDir/classes/main"
        include "pvx/core/util/DesEncrypter.class"
    }
}
+4
source share
1 answer

It should be:

task utilJar(dependsOn:classes, type: Jar) {
   archiveName "DesEncrypter-${version}.jar"
   manifest { attributes "Created-By": "1.8.0_60 (Oracle Corporation)" }
   from("$buildDir/classes/main") {
      include "pvx/core/util/DesEncrypter.class"
   }
}
+1
source

Source: https://habr.com/ru/post/1611824/


All Articles