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,8 +20,6 @@ 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
2430 }
2531}
2632
27- tasks. withType(JavaCompile ) { // compile-time options:
33+ tasks. withType(JavaCompile ). configureEach { // compile-time options:
2834 // options.compilerArgs << '-Xlint:deprecation' // to show deprecation warnings
2935 options. compilerArgs << ' -Xlint:unchecked'
3036 options. encoding = ' UTF-8'
@@ -44,8 +50,10 @@ dependencies {
4450 testImplementation libs. junit. jupiter
4551 testImplementation libs. mokito. core
4652 testImplementation libs. mokito. junit. jupiter
47- testImplementation libs. groovy. test
4853 testRuntimeOnly libs. junit. platform. launcher
54+ if (groovySourcePresent) {
55+ testImplementation libs. groovy. test
56+ }
4957}
5058
5159// Uncomment if you want to see the status of every test that is run and
6775 }
6876}
6977
70- javadoc {
78+ tasks . named( ' javadoc' , Javadoc ) {
7179 failOnError = false
7280 options. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel . PROTECTED
7381 options. docTitle = " jMonkeyEngine ${ jmeFullVersion} ${ project.name} Javadoc"
@@ -90,14 +98,18 @@ test {
9098 }
9199}
92100
93- task sourcesJar (type : Jar , dependsOn : classes, description : ' Creates a jar from the source files.' ) {
101+ def sourcesJar = tasks. register(' sourcesJar' , Jar ) {
102+ dependsOn classes
103+ description = ' Creates a jar from the source files.'
94104 archiveClassifier = ' sources'
95105 from sourceSets* . allSource
96106}
97107
98- task javadocJar (type : Jar , dependsOn : javadoc, description : ' Creates a jar from the javadoc files.' ) {
108+ def javadocJar = tasks. register(' javadocJar' , Jar ) {
109+ dependsOn javadoc
110+ description = ' Creates a jar from the javadoc files.'
99111 archiveClassifier = ' javadoc'
100- from javadoc. destinationDir
112+ from tasks . named( ' javadoc' , Javadoc ) . map { it . destinationDir }
101113}
102114
103115ext. pomConfig = {
@@ -125,18 +137,16 @@ ext.pomConfig = {
125137 }
126138}
127139
128- tasks. named(' assemble' ) {
129- dependsOn sourcesJar
130- if (buildJavaDoc == " true" ) {
131- dependsOn javadocJar
132- }
133- }
140+ def hasSigningKey = providers. gradleProperty(' signingKey' ). isPresent()
141+ def publishedModuleName = " ${ project.name} -${ jmeFullVersion} "
134142
135143publishing {
136144 publications {
137145 maven(MavenPublication ) {
138- artifact javadocJar
139146 artifact sourcesJar
147+ if (buildJavaDoc == " true" ) {
148+ artifact javadocJar
149+ }
140150 from components. java
141151 pom {
142152 description = POM_DESCRIPTION
@@ -197,10 +207,12 @@ publishing {
197207 }
198208}
199209
200- publishToMavenLocal. doLast {
201- println ' published ' + project. getName() + " -${ jmeFullVersion} to mavenLocal"
210+ tasks. named(' publishToMavenLocal' ) {
211+ doLast {
212+ println " published ${ publishedModuleName} to mavenLocal"
213+ }
202214}
203- task (' install' ) {
215+ tasks . register (' install' ) {
204216 dependsOn ' publishToMavenLocal'
205217}
206218
@@ -211,8 +223,8 @@ signing {
211223
212224 sign publishing. publications. maven
213225}
214- tasks. withType(Sign ) {
215- onlyIf { gradle . rootProject . hasProperty( ' signingKey ' ) }
226+ tasks. withType(Sign ). configureEach {
227+ onlyIf { hasSigningKey }
216228}
217229
218230def checkstyleSupported = JavaVersion . current(). isCompatibleWith(JavaVersion . VERSION_21 )
@@ -230,7 +242,7 @@ checkstyleTest {
230242 source = ' src/test/java'
231243}
232244
233- tasks. withType(Checkstyle ) {
245+ tasks. withType(Checkstyle ). configureEach {
234246 enabled = checkstyleSupported
235247 reports {
236248 xml. required. set(false )
0 commit comments