diff --git a/fineract-core/build.gradle b/fineract-core/build.gradle index c05ff728866..345847cc108 100644 --- a/fineract-core/build.gradle +++ b/fineract-core/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Core' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() +tasks.register('staticWeaveJpa', JavaExec) { + group = "build" + description = "Performs EclipseLink static weaving of entity classes" + + dependsOn classes + + def classesDir = sourceSets.main.java.classesDirectory.get() copy { from file("src/main/resources/jpa/core/persistence.xml") - into "${source}/META-INF/" - } - javaexec { - description = 'Performs EclipseLink static weaving of entity classes' - def target = source - main = 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave' - args '-persistenceinfo', source, source, target - classpath sourceSets.main.runtimeClasspath - } - delete { - delete "${source}/META-INF/persistence.xml" + into "${classesDir}/META-INF/" } + + mainClass.set('org.eclipse.persistence.tools.weaving.jpa.StaticWeave') + classpath = sourceSets.main.runtimeClasspath + args '-persistenceinfo', classesDir, classesDir, classesDir +} + +staticWeaveJpa.doLast { + delete "${sourceSets.main.output.classesDirs.asPath}/META-INF/persistence.xml" +} + +tasks.named('classes') { + finalizedBy staticWeaveJpa +} + +tasks.named('processResources') { + from('src/main/resources') + into sourceSets.main.java.classesDirectory + outputs.upToDateWhen { false } } configurations {