add extensions in deploy json
"extensions" : {
"build": {
"class":"xxx.XPlugin",
"url: "http://xxxxx.jar",
"md5sum" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
},
add extensions jar in ext dir
exts:
- plugin_a.jar
- plugin_b.jar
package xxx;
import org.json.JSONObject;
import javax.annotation.Resource;
public class XPlugin {
@Resource
private JSONObject deployJson;
private String buildDir;
private String srcDir;
public void beforeTask(){
System.out.println("buildDir:" + buildDir + " srcDir:" + srcDir);
}
public void runTask(){
System.out.println("deployJson:" + deployJson);
}
public void afterTask(){
System.out.println("after@@@@@@@@@");
}
}
then compile class to exts dir: javac -d ~/opt/jobdeploy/exts XPlugin.java -cp ~/.m2/repository/org/json/json/20230227/json-20230227.jar
then ~/opt/jobdeploy/exts dir: xxx/XPlugin.class
the extension will call when method defined in class
field use @Resource support Inject by spring string filed inject support: buildDir srcDir