Skip to content

Commit a76c189

Browse files
committed
Revert "FINERACT-2181: Some tweaks in the gradle build to ensure correct task processing"
This reverts commit 6cb60f4
1 parent 1ebfad2 commit a76c189

File tree

36 files changed

+396
-525
lines changed

36 files changed

+396
-525
lines changed

build.gradle

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ configure(project.fineractJavaProjects) {
365365
withJavadocJar()
366366
}
367367

368-
tasks.withType(ProcessResources).configureEach {
368+
tasks.withType(ProcessResources) {
369369
destinationDir = layout.buildDirectory.dir('classes/java/main').get().asFile
370370
}
371371

372372
// Add performance optimizations
373-
configurations.configureEach {
373+
configurations.all {
374374
resolutionStrategy {
375375
cacheChangingModulesFor 0, 'seconds'
376376
cacheDynamicVersionsFor 0, 'seconds'
@@ -422,40 +422,40 @@ configure(project.fineractJavaProjects) {
422422
configurations {
423423
api.setCanBeResolved(true)
424424
}
425-
tasks.withType(Copy).configureEach {
425+
tasks.withType(Copy) {
426426
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
427427
}
428-
tasks.withType(JavaCompile).configureEach {
428+
tasks.withType(JavaCompile) {
429429
options.compilerArgs += [
430-
"-Xlint:cast",
431-
"-Xlint:auxiliaryclass",
432-
"-Xlint:dep-ann",
433-
"-Xlint:divzero",
434-
"-Xlint:empty",
435-
"-Xlint:exports",
436-
"-Xlint:fallthrough",
437-
"-Xlint:finally",
438-
"-Xlint:module",
439-
"-Xlint:opens",
440-
"-Xlint:options",
441-
"-Xlint:overloads",
442-
"-Xlint:overrides",
443-
"-Xlint:path",
444-
"-Xlint:processing",
445-
"-Xlint:removal",
446-
"-Xlint:requires-automatic",
447-
"-Xlint:requires-transitive-automatic",
448-
"-Xlint:try",
449-
"-Xlint:varargs",
450-
"-Xlint:preview",
451-
"-Xlint:static",
452-
// -Werror needs to be disabled because EclipseLink's static weaving doesn't generate warning-free code
453-
// and during an IntelliJ recompilation, it fails
454-
//"-Werror",
455-
"-Xmaxwarns",
456-
"1500",
457-
"-Xmaxerrs",
458-
"1500"
430+
"-Xlint:cast",
431+
"-Xlint:auxiliaryclass",
432+
"-Xlint:dep-ann",
433+
"-Xlint:divzero",
434+
"-Xlint:empty",
435+
"-Xlint:exports",
436+
"-Xlint:fallthrough",
437+
"-Xlint:finally",
438+
"-Xlint:module",
439+
"-Xlint:opens",
440+
"-Xlint:options",
441+
"-Xlint:overloads",
442+
"-Xlint:overrides",
443+
"-Xlint:path",
444+
"-Xlint:processing",
445+
"-Xlint:removal",
446+
"-Xlint:requires-automatic",
447+
"-Xlint:requires-transitive-automatic",
448+
"-Xlint:try",
449+
"-Xlint:varargs",
450+
"-Xlint:preview",
451+
"-Xlint:static",
452+
// -Werror needs to be disabled because EclipseLink's static weaving doesn't generate warning-free code
453+
// and during an IntelliJ recompilation, it fails
454+
//"-Werror",
455+
"-Xmaxwarns",
456+
"1500",
457+
"-Xmaxerrs",
458+
"1500"
459459
]
460460
// TODO FINERACT-959 (gradually) enable -Xlint:all (see "javac -help -X")
461461

@@ -738,13 +738,11 @@ configure(project.fineractJavaProjects) {
738738
]
739739
}
740740

741-
tasks.withType(Javadoc).tap {
742-
configureEach {
743-
options.addStringOption('Xdoclint:none', '-quiet')
744-
options.encoding = 'UTF-8'
745-
// Ignore any errors during javadoc generation
746-
failOnError = false
747-
}
741+
tasks.withType(Javadoc) {
742+
options.addStringOption('Xdoclint:none', '-quiet')
743+
options.encoding = 'UTF-8'
744+
// Ignore any errors during javadoc generation
745+
failOnError = false
748746
}
749747
}
750748

@@ -870,17 +868,17 @@ configure(project.fineractPublishProjects) {
870868
}
871869
}
872870

873-
tasks.register('printSourceSetInformation') {
874-
doLast {
875-
sourceSets.each { srcSet ->
876-
println "[" + srcSet.name + "]"
877-
print "-->Source directories: " + srcSet.allJava.srcDirs + "\n"
878-
print "-->Output directories: " + srcSet.output.classesDirs.files + "\n"
879-
print "-->Compile classpath:\n"
880-
srcSet.compileClasspath.files.each {
881-
print " " + it.path + "\n"
882-
}
883-
println ""
871+
task printSourceSetInformation() {
872+
doLast{
873+
sourceSets.each { srcSet ->
874+
println "["+srcSet.name+"]"
875+
print "-->Source directories: "+srcSet.allJava.srcDirs+"\n"
876+
print "-->Output directories: "+srcSet.output.classesDirs.files+"\n"
877+
print "-->Compile classpath:\n"
878+
srcSet.compileClasspath.files.each {
879+
print " "+it.path+"\n"
884880
}
881+
println ""
885882
}
886883
}
884+
}

fineract-accounting/build.gradle

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,23 @@ description = 'Fineract Accounting'
2121
apply plugin: 'java'
2222
apply plugin: 'eclipse'
2323

24-
tasks.register('staticWeaveJpa', JavaExec) {
25-
group = "build"
26-
description = "Performs EclipseLink static weaving of entity classes"
27-
28-
dependsOn classes
29-
30-
def classesDir = file("$buildDir/classes/java/main")
31-
32-
mainClass.set('org.eclipse.persistence.tools.weaving.jpa.StaticWeave')
33-
classpath = sourceSets.main.runtimeClasspath
34-
args '-persistenceinfo', classesDir.absolutePath, classesDir.absolutePath, classesDir.absolutePath
35-
}
36-
37-
staticWeaveJpa.doLast {
38-
delete "${sourceSets.main.output.classesDirs.asPath}/META-INF/persistence.xml"
39-
}
40-
41-
tasks.named('classes') {
42-
finalizedBy staticWeaveJpa
43-
}
44-
45-
tasks.named('processResources') {
46-
from('src/main/resources')
47-
into sourceSets.main.java.classesDirectory
48-
outputs.upToDateWhen { false }
49-
}
50-
51-
compileJava {
52-
dependsOn ':fineract-avro-schemas:buildJavaSdk'
24+
compileJava.doLast {
25+
def mainSS = sourceSets.main
26+
def source = mainSS.java.classesDirectory.get()
27+
copy {
28+
from file("src/main/resources/jpa/accounting/persistence.xml")
29+
into "${source}/META-INF/"
30+
}
31+
javaexec {
32+
description = 'Performs EclipseLink static weaving of entity classes'
33+
def target = source
34+
mainClass = 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
35+
args '-persistenceinfo', source, source, target
36+
classpath sourceSets.main.runtimeClasspath
37+
}
38+
delete {
39+
delete "${source}/META-INF/persistence.xml"
40+
}
5341
}
5442

5543
configurations {
@@ -97,6 +85,10 @@ eclipse {
9785
}
9886
}
9987

88+
/* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */
89+
sourceSets.main.output.resourcesDir = sourceSets.main.java.classesDirectory
90+
sourceSets.test.output.resourcesDir = sourceSets.test.java.classesDirectory
91+
10092
if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
10193
sourceSets {
10294
test {

fineract-accounting/src/main/resources/db/changelog/tenant/module/accounting/module-changelog-master.xml renamed to fineract-accounting/src/main/resources/jpa/accounting/db/changelog/tenant/module/accounting/module-changelog-master.xml

File renamed without changes.

fineract-accounting/src/main/resources/META-INF/persistence.xml renamed to fineract-accounting/src/main/resources/jpa/accounting/persistence.xml

File renamed without changes.

fineract-avro-schemas/build.gradle

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ tasks.register('preprocessAvroSchemas', PreprocessAvroSchemasTask) {
5757
inputDir = file("$projectDir/src/main/avro")
5858
bigDecimalTemplate = file("$projectDir/src/main/resources/avro-templates/bigdecimal.avsc")
5959
outputDir = file("$buildDir/generated/avro/src/main/avro")
60-
finalizedBy buildJavaSdk
6160
}
6261

63-
tasks.register('buildJavaSdk', GenerateAvroJavaTask) {
64-
dependsOn preprocessAvroSchemas, spotlessJsonApply
62+
task buildJavaSdk(type: GenerateAvroJavaTask) {
6563
source("$buildDir/generated/avro/src/main/avro")
6664
outputDir = file("$buildDir/generated/java/src/main/java")
6765
templateDirectory = "$projectDir/src/main/resources/avro-generator-templates/"
@@ -75,10 +73,12 @@ spotless {
7573
}
7674
}
7775

76+
buildJavaSdk.dependsOn(preprocessAvroSchemas, spotlessJsonApply)
77+
7878
sourceSets {
7979
main {
8080
java {
81-
srcDirs += "$buildDir/generated/java/src/main/java"
81+
srcDir file("$buildDir/generated/java/src/main/java")
8282
}
8383
resources {
8484
srcDir file("$projectDir/src/main/resources")
@@ -97,7 +97,7 @@ jar {
9797
}
9898

9999
compileJava {
100-
dependsOn buildJavaSdk, processResources
100+
dependsOn buildJavaSdk
101101
source = sourceSets.main.java.srcDirs
102102
options.compilerArgs += ['-parameters']
103103
}
@@ -131,9 +131,3 @@ tasks.named('sourcesJar') {
131131
dependsOn tasks.named('buildJavaSdk')
132132
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
133133
}
134-
135-
tasks.named('processResources') {
136-
from('src/main/resources')
137-
into sourceSets.main.java.classesDirectory
138-
outputs.upToDateWhen { false }
139-
}

fineract-branch/build.gradle

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,23 @@ description = 'Fineract Branch'
2121
apply plugin: 'java'
2222
apply plugin: 'eclipse'
2323

24-
tasks.register('staticWeaveJpa', JavaExec) {
25-
group = "build"
26-
description = "Performs EclipseLink static weaving of entity classes"
27-
28-
dependsOn classes
29-
30-
def classesDir = file("$buildDir/classes/java/main")
31-
32-
mainClass.set('org.eclipse.persistence.tools.weaving.jpa.StaticWeave')
33-
classpath = sourceSets.main.runtimeClasspath
34-
args '-persistenceinfo', classesDir.absolutePath, classesDir.absolutePath, classesDir.absolutePath
35-
}
36-
37-
staticWeaveJpa.doLast {
38-
delete "${sourceSets.main.output.classesDirs.asPath}/META-INF/persistence.xml"
39-
}
40-
41-
tasks.named('classes') {
42-
finalizedBy staticWeaveJpa
43-
}
44-
45-
tasks.named('processResources') {
46-
from('src/main/resources')
47-
into sourceSets.main.java.classesDirectory
48-
outputs.upToDateWhen { false }
49-
}
50-
51-
compileJava {
52-
dependsOn ':fineract-avro-schemas:buildJavaSdk'
24+
compileJava.doLast {
25+
def mainSS = sourceSets.main
26+
def source = mainSS.java.classesDirectory.get()
27+
copy {
28+
from file("src/main/resources/jpa/branch/persistence.xml")
29+
into "${source}/META-INF/"
30+
}
31+
javaexec {
32+
description = 'Performs EclipseLink static weaving of entity classes'
33+
def target = source
34+
main 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
35+
args '-persistenceinfo', source, source, target
36+
classpath sourceSets.main.runtimeClasspath
37+
}
38+
delete {
39+
delete "${source}/META-INF/persistence.xml"
40+
}
5341
}
5442

5543
// Configuration for Swagger documentation generation task
@@ -103,6 +91,10 @@ eclipse {
10391
}
10492
}
10593

94+
/* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */
95+
sourceSets.main.output.resourcesDir = sourceSets.main.java.classesDirectory
96+
sourceSets.test.output.resourcesDir = sourceSets.test.java.classesDirectory
97+
10698
if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
10799
sourceSets {
108100
test {

fineract-branch/src/main/resources/META-INF/persistence.xml renamed to fineract-branch/src/main/resources/jpa/branch/persistence.xml

File renamed without changes.

fineract-charge/build.gradle

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,23 @@ description = 'Fineract Charge'
2121
apply plugin: 'java'
2222
apply plugin: 'eclipse'
2323

24-
tasks.register('staticWeaveJpa', JavaExec) {
25-
group = "build"
26-
description = "Performs EclipseLink static weaving of entity classes"
27-
28-
dependsOn classes
29-
30-
def classesDir = file("$buildDir/classes/java/main")
31-
32-
mainClass.set('org.eclipse.persistence.tools.weaving.jpa.StaticWeave')
33-
classpath = sourceSets.main.runtimeClasspath
34-
args '-persistenceinfo', classesDir.absolutePath, classesDir.absolutePath, classesDir.absolutePath
35-
}
36-
37-
staticWeaveJpa.doLast {
38-
delete "${sourceSets.main.output.classesDirs.asPath}/META-INF/persistence.xml"
39-
}
40-
41-
tasks.named('classes') {
42-
finalizedBy staticWeaveJpa
43-
}
44-
45-
tasks.named('processResources') {
46-
from('src/main/resources')
47-
into sourceSets.main.java.classesDirectory
48-
outputs.upToDateWhen { false }
49-
}
50-
51-
compileJava {
52-
dependsOn ':fineract-avro-schemas:buildJavaSdk'
24+
compileJava.doLast {
25+
def mainSS = sourceSets.main
26+
def source = mainSS.java.classesDirectory.get()
27+
copy {
28+
from file("src/main/resources/jpa/charge/persistence.xml")
29+
into "${source}/META-INF/"
30+
}
31+
javaexec {
32+
description = 'Performs EclipseLink static weaving of entity classes'
33+
def target = source
34+
main 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
35+
args '-persistenceinfo', source, source, target
36+
classpath sourceSets.main.runtimeClasspath
37+
}
38+
delete {
39+
delete "${source}/META-INF/persistence.xml"
40+
}
5341
}
5442

5543
// Configuration for Swagger documentation generation task
@@ -103,6 +91,10 @@ eclipse {
10391
}
10492
}
10593

94+
/* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */
95+
sourceSets.main.output.resourcesDir = sourceSets.main.java.classesDirectory
96+
sourceSets.test.output.resourcesDir = sourceSets.test.java.classesDirectory
97+
10698
if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
10799
sourceSets {
108100
test {

fineract-charge/src/main/resources/db/changelog/tenant/module/charge/module-changelog-master.xml renamed to fineract-charge/src/main/resources/jpa/charge/db/changelog/tenant/module/charge/module-changelog-master.xml

File renamed without changes.

fineract-charge/src/main/resources/META-INF/persistence.xml renamed to fineract-charge/src/main/resources/jpa/charge/persistence.xml

File renamed without changes.

0 commit comments

Comments
 (0)