有没有办法将编程创建的Drools 6工件部署到底层maven存储库?我不想以某种方式明确地调用mvn deploy
,而是从程序本身执行此操作:
public static void main(String[] args) {
String ruleString = "rule \"TestRule\"\nthen\nSystem.out.println(\"This is a testrule.\");\nend";
KieServices kieServices = KieServices.Factory.get();
KieModuleModel kieModuleModel = kieServices.newKieModuleModel();
KieBaseModel kieBaseModel = kieModuleModel.newKieBaseModel("testbase1").setDefault(true);
KieSessionModel kieSessionModel = kieBaseModel.newKieSessionModel("testsession1").setDefault(true).setType(KieSessionModel.KieSessionType.STATELESS);
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
kieFileSystem.generateAndWritePomXML(new ReleaseIdImpl("de.itm.test", "testartifact", "0.0.1-SNAPSHOT"));
kieFileSystem.write("src/main/resources/testbase1/rule1.drl", ruleString);
KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem).buildAll();
// how to now deploy the new artifact so it is available on disc, e.g. in ~/.m2/repository/de/itm/test/test/testartifact/0.0.1-SNAPSHOT/ ?
}
答案 0 :(得分:4)
在这里,您可以看到满足您要求的单元测试:
基本上:
MavenRepository repository = MavenRepository.getMavenRepository();
repository.deployArtifact(releaseId, kJar1, kPom);