Gradle Plugin - nsoft/uno-jar GitHub Wiki

Gradle Plugin

New Plugin (1.1+)

In 1.1 a new plugin written as an actual Gradle task written in java was contributed. It can be configured as follows for the simplest case

unojar {
    archivesBaseName = 'myJarName'
    mainClass = 'org.example.MyNiftyClass'
}

Running the packageUnoJar task in gradle will then result in myJarName-SNAPSHOT-1.0.jar (the base library) and in myJarName-SNAPSHOT-1.0-unojar.jar (the unojar)

ℹ️
To Do: more documentation of all the options, which have changed substantially. A more advanced configuration can be seen here: https://github.com/nsoft/jesterj/blob/4e7161c5988286417565dc00c72390b3e47cdc82/code/ingest/build.gradle#L497

Old Ant Based Plugin (through 1.0.x)

Early versions Satisfied the need for a plugin expediently via a .groovy class that leaned heavily on hacks to actually run the ant task under the covers. For early versions the following works, but if there are bugs, upgrading to 1.1 is recommended since the Java based version will be supported going forward:

plugins {
  id "com.needhamsoftware.unojar" version "0.99"
}

unojar {
  unoJar "build/testJar2.jar"                        // <<< (1)
  manifestAttrs ("Test-Attribute" : "TestValue")     // <<< (2)
  appMainClass "com.needhamsoftware.unojar.TestMain" // <<< (3)
  appFiles {                                         // <<< (4)
    fileset(dir: 'build/classes/java/test') {
      include(name: '**/TestMain.class')
    }
  }
  depLibs {                                          // <<< (5)
    fileset(dir: 'build/libs') {
      include(name: 'libtest.jar')
    }
  }
}

Note that the above attribute names differ from the ant task intentionally. The original names used by One-JAR were focused on and corresponded to the internal structure of the final jar file. These names take a user oriented perspective and hopefully make some sense to a user who is unaware of the internal structure of the final jar file.

  1. Where to output the final jar file.

  2. Supply a groovy map to populate manifest attributes at the top level This does NOT add manifest attributes to the jar file containing the application within the uno-jar.

  3. This is the preferred method for setting the main application class. This will overwrite anything set using manifest()

  4. This should specify where to find the .class files and any other files that should be available as resources. In a typical gradle project this will be stuff from build/classes. This currently has no default, but future versions will likely default to build/classes/java/main and build/resources/main

  5. This should specify the dependent libraries. Presently this has no default, but in the future it will likely default to the runtime configuration for the main project.

Presently there is no way to configure multiple Uno-Jars per project. Future versions will provide a task class that can be appropriately configured to support multiple Uno-Jars

⚠️ **GitHub.com Fallback** ⚠️