将以编程方式创建的KIE-Drools-Artifact部署到Maven存储库

时间:2014-03-12 15:12:31

标签: drools kie

有没有办法将编程创建的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/ ?
}

1 个答案:

答案 0 :(得分:4)

在这里,您可以看到满足您要求的单元测试:

https://github.com/kiegroup/drools/blob/master/kie-ci/src/test/java/org/kie/scanner/KieScannerIncrementalCompilationTest.java#L63

基本上:

MavenRepository repository = MavenRepository.getMavenRepository();
repository.deployArtifact(releaseId, kJar1, kPom);