gradle构建时不会生成Clojure声明规则文件 编辑:

问题描述

我有一个Spring应用程序,该应用程序集成了从java类触发的clara规则引擎(clojure)文件。使用gradle构建应用程序时,clojure文件不会作为JAR的一部分生成。

因此,在运行the jar时,它将引发以下异常:

Caused by: java.io.FileNotFoundException: Could not locate au/com/acme/mti/mec/runtime/rules/mec__init.class or au/com/acme/mti/mec/runtime/rules/mec.clj on classpath.

在构建/生成jar时,使gradle生成clj文件的最佳方法(或至少一种方法)是什么?

我已经在build.gradle文件中包含一个任务,用于将clj文件从src路径复制到构建路径。它将文件复制到构建路径下,但不在jar中。

build.gradle:

plugins {
    id 'org.springframework.boot' version '2.3.1.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
    id 'jacoco'
}

group = 'au.com.acme.mti.mec'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
    mavenLocal()
    maven {
        url "http://clojars.org/repo"
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.clojure:clojure:1.9.0'
    implementation 'com.cerner:clara-rules:0.20.0'
    implementation 'org.projectlombok:lombok'
    
    }
    
}

task copyRules(type: Copy){
    from 'src/main/resources/au.com.acme.mti.mec.runtime.rules/'
    into 'build/classes/java/main/au/com/acme/mti/mec/runtime/rules/'
}

test {
    test.dependsOn copyRules
    useJUnitPlatform()
    finalizedBy jacocoTestReport
}

jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.destination file("${buildDir}/jacocoHtml")
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)