33//
44
55apply plugin : ' java-library'
6- apply plugin : ' groovy'
6+ group = ' org.jmonkeyengine'
7+ version = jmeFullVersion
8+
9+ def groovySourcePresent = project. file(' src/main/groovy' ). exists() || project. file(' src/test/groovy' ). exists()
10+
11+ if (groovySourcePresent) {
12+ apply plugin : ' groovy'
13+ }
14+
715apply plugin : ' maven-publish'
816apply plugin : ' signing'
917apply plugin : ' eclipse'
@@ -12,15 +20,13 @@ apply plugin: 'checkstyle'
1220eclipse. jdt. file. withProperties { props ->
1321 props. setProperty " org.eclipse.jdt.core.circularClasspath" , " warning"
1422}
15- group = ' org.jmonkeyengine'
16- version = jmeFullVersion
1723
1824java {
1925 sourceCompatibility = JavaVersion . VERSION_1_8
2026 targetCompatibility = JavaVersion . VERSION_1_8
2127}
2228
23- tasks. withType(JavaCompile ) { // compile-time options:
29+ tasks. withType(JavaCompile ). configureEach { // compile-time options:
2430 // options.compilerArgs << '-Xlint:deprecation' // to show deprecation warnings
2531 options. compilerArgs << ' -Xlint:unchecked'
2632 options. encoding = ' UTF-8'
@@ -42,8 +48,10 @@ dependencies {
4248 testImplementation libs. junit. jupiter
4349 testImplementation libs. mokito. core
4450 testImplementation libs. mokito. junit. jupiter
45- testImplementation libs. groovy. test
4651 testRuntimeOnly libs. junit. platform. launcher
52+ if (groovySourcePresent) {
53+ testImplementation libs. groovy. test
54+ }
4755}
4856
4957// Uncomment if you want to see the status of every test that is run and
6573 }
6674}
6775
68- javadoc {
76+ tasks . named( ' javadoc' , Javadoc ) {
6977 failOnError = false
7078 options. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel . PROTECTED
7179 options. docTitle = " jMonkeyEngine ${ jmeFullVersion} ${ project.name} Javadoc"
@@ -88,14 +96,18 @@ test {
8896 }
8997}
9098
91- task sourcesJar (type : Jar , dependsOn : classes, description : ' Creates a jar from the source files.' ) {
99+ def sourcesJar = tasks. register(' sourcesJar' , Jar ) {
100+ dependsOn classes
101+ description = ' Creates a jar from the source files.'
92102 archiveClassifier = ' sources'
93103 from sourceSets* . allSource
94104}
95105
96- task javadocJar (type : Jar , dependsOn : javadoc, description : ' Creates a jar from the javadoc files.' ) {
106+ def javadocJar = tasks. register(' javadocJar' , Jar ) {
107+ dependsOn javadoc
108+ description = ' Creates a jar from the javadoc files.'
97109 archiveClassifier = ' javadoc'
98- from javadoc. destinationDir
110+ from tasks . named( ' javadoc' , Javadoc ) . map { it . destinationDir }
99111}
100112
101113ext. pomConfig = {
@@ -123,18 +135,16 @@ ext.pomConfig = {
123135 }
124136}
125137
126- tasks. named(' assemble' ) {
127- dependsOn sourcesJar
128- if (buildJavaDoc == " true" ) {
129- dependsOn javadocJar
130- }
131- }
138+ def hasSigningKey = providers. gradleProperty(' signingKey' ). isPresent()
139+ def publishedModuleName = " ${ project.name} -${ jmeFullVersion} "
132140
133141publishing {
134142 publications {
135143 maven(MavenPublication ) {
136- artifact javadocJar
137144 artifact sourcesJar
145+ if (buildJavaDoc == " true" ) {
146+ artifact javadocJar
147+ }
138148 from components. java
139149 pom {
140150 description = POM_DESCRIPTION
@@ -195,10 +205,12 @@ publishing {
195205 }
196206}
197207
198- publishToMavenLocal. doLast {
199- println ' published ' + project. getName() + " -${ jmeFullVersion} to mavenLocal"
208+ tasks. named(' publishToMavenLocal' ) {
209+ doLast {
210+ println " published ${ publishedModuleName} to mavenLocal"
211+ }
200212}
201- task (' install' ) {
213+ tasks . register (' install' ) {
202214 dependsOn ' publishToMavenLocal'
203215}
204216
@@ -209,8 +221,8 @@ signing {
209221
210222 sign publishing. publications. maven
211223}
212- tasks. withType(Sign ) {
213- onlyIf { gradle . rootProject . hasProperty( ' signingKey ' ) }
224+ tasks. withType(Sign ). configureEach {
225+ onlyIf { hasSigningKey }
214226}
215227
216228def checkstyleSupported = JavaVersion . current(). isCompatibleWith(JavaVersion . VERSION_21 )
@@ -228,7 +240,7 @@ checkstyleTest {
228240 source = ' src/test/java'
229241}
230242
231- tasks. withType(Checkstyle ) {
243+ tasks. withType(Checkstyle ). configureEach {
232244 enabled = checkstyleSupported
233245 reports {
234246 xml. required. set(false )
0 commit comments