Skip to content

Latest commit

 

History

History
49 lines (45 loc) · 1.91 KB

File metadata and controls

49 lines (45 loc) · 1.91 KB

Principle

  • If plugin doesn't rely on any 3rd-party libs, normal jar is enough.
    • You still need to sign jar manifest as below example
  • Fat-jar format (jar in jar) is not supported at the moment. There are two walkaround solutions:
    • Flat lib jar, then pack all classes and resources into on jar file. (as the below gradle example)
    • Use zip format, put all 3rd-parth libs jar under /lib, then pack into zip file with /classes.

Gradle

This revision demonstrates how to build plugin JAR for production mode.

Breakdown

  • Add configuration of plugin libs, so later then could be packed in to the jar.
  configurations {
      localLibs
      compile.extendsFrom(localLibs)
  }

  dependencies {
      localLibs fileTree(dir: 'libs', include: '**')
      ......
  }
  • Add a task to build the jar. The most important thing is to set the manifest of the jar could it could be recognized as a plugin.
    task buildPlugin(type: Jar) {
        ......
        manifest.attributes(
                "Plugin-Id": pluginProp.get("plugin.id"),
                "Plugin-Class": pluginProp.get("plugin.class"),
                "Plugin-Version": pluginProp.get("plugin.version"),
                "Plugin-Provider": pluginProp.get("plugin.provider"),
                "Plugin-Dependencies": pluginProp.get("plugin.dependencies"))
        ......
    }
  • flat all classes of dependent jars and repack them to a new jar. The default JarPluginLoader is not able to nested jars in side of jar, e.g. Spring executable jar.
    task buildPlugin(type: Jar) {
        ......
        from configurations.localLibs.asFileTree.files.collect { zipTree(it) }
        ......
    }

Maven

NEED YOUR HELP!