Skip to content

Commit 7ca869d

Browse files
committed
Trim default Gradle build outputs
1 parent e734b88 commit 7ca869d

File tree

5 files changed

+163
-115
lines changed

5 files changed

+163
-115
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138
uses: gradle/actions/wrapper-validation@v5.0.2
139139
- name: Test with Gradle Wrapper
140140
run: |
141-
./gradlew :jme3-screenshot-test:screenshotTest
141+
./gradlew :jme3-screenshot-tests:screenshotTest
142142
- name: Upload Test Reports
143143
uses: actions/upload-artifact@v7.0.0
144144
if: always()
@@ -285,8 +285,7 @@ jobs:
285285
shell: bash
286286
run: |
287287
# Normal build plus ZIP distribution and merged javadoc
288-
./gradlew -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true \
289-
-x checkstyleMain -x checkstyleTest \
288+
./gradlew -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true -PbuildJavaDoc=true \
290289
build createZipDistribution mergedJavadoc
291290
292291
if [ "${{ matrix.deploy }}" = "true" ];
@@ -306,13 +305,13 @@ jobs:
306305
echo "SIGNING_KEY, SIGNING_PASSWORD"
307306
308307
./gradlew publishMavenPublicationToDistRepository \
309-
-PskipPrebuildLibraries=true -PuseCommitHashAsVersionName=true \
308+
-PskipPrebuildLibraries=true -PuseCommitHashAsVersionName=true -PbuildJavaDoc=true \
310309
--console=plain --stacktrace
311310
else
312311
./gradlew publishMavenPublicationToDistRepository \
313312
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
314313
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
315-
-PskipPrebuildLibraries=true -PuseCommitHashAsVersionName=true \
314+
-PskipPrebuildLibraries=true -PuseCommitHashAsVersionName=true -PbuildJavaDoc=true \
316315
--console=plain --stacktrace
317316
fi
318317
@@ -491,6 +490,7 @@ jobs:
491490
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
492491
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
493492
-PuseCommitHashAsVersionName=true \
493+
-PbuildJavaDoc=true \
494494
--console=plain --stacktrace
495495
fi
496496
@@ -554,6 +554,7 @@ jobs:
554554
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
555555
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
556556
-PuseCommitHashAsVersionName=true \
557+
-PbuildJavaDoc=true \
557558
--console=plain --stacktrace
558559
.github/actions/tools/uploadToCentral.sh \
559560
-p '${{ secrets.CENTRAL_PASSWORD }}' \

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,14 @@ Run the Gradle wrapper:
139139

140140
After a successful build,
141141
snapshot jars will be found in the "*/build/libs" subfolders.
142+
The default build skips JavaDoc and source archives for speed; release and
143+
publishing tasks build them explicitly.
142144

143145
### Related Gradle tasks
144146

145147
You can install the Maven artifacts to your local repository:
146-
+ using Bash or PowerShell: `./gradlew install`
147-
+ using Windows Command Prompt: `.\gradlew install`
148+
+ using Bash or PowerShell: `./gradlew -PbuildJavaDoc=true install`
149+
+ using Windows Command Prompt: `.\gradlew -PbuildJavaDoc=true install`
148150

149151
You can restore the project to a pristine state:
150152
+ using Bash or PowerShell: `./gradlew clean`

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ Read our [contribution guide](https://github.com/jMonkeyEngine/jmonkeyengine/blo
9797

9898
After a successful build,
9999
fresh JARs will be found in "*/build/libs".
100+
The default build skips JavaDoc and source archives for speed; release and
101+
publishing tasks build them explicitly.
100102

101103
You can install the JARs to your local Maven repository:
102-
+ using Bash or Fish or PowerShell or Zsh: `./gradlew install`
103-
+ using Windows Command Prompt: `.\gradlew install`
104+
+ using Bash or Fish or PowerShell or Zsh: `./gradlew -PbuildJavaDoc=true install`
105+
+ using Windows Command Prompt: `.\gradlew -PbuildJavaDoc=true install`
104106

105107
You can run the "jme3-examples" app:
106108
+ using Bash or Fish or PowerShell or Zsh: `./gradlew run`

common.gradle

Lines changed: 142 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,52 @@
33
//
44

55
apply plugin: 'java-library'
6-
apply plugin: 'groovy'
7-
apply plugin: 'maven-publish'
8-
apply plugin: 'signing'
9-
apply plugin: 'eclipse'
10-
apply plugin: 'checkstyle'
11-
12-
eclipse.jdt.file.withProperties { props ->
13-
props.setProperty "org.eclipse.jdt.core.circularClasspath", "warning"
14-
}
156
group = 'org.jmonkeyengine'
167
version = jmeFullVersion
178

9+
def requestedTasks = gradle.startParameter.taskNames
10+
def taskRequested = { String taskName ->
11+
requestedTasks.any { requested ->
12+
requested == taskName || requested.endsWith(":${taskName}")
13+
}
14+
}
15+
def taskNameContains = { String fragment ->
16+
requestedTasks.any { requested ->
17+
requested.toLowerCase(Locale.ROOT).contains(fragment.toLowerCase(Locale.ROOT))
18+
}
19+
}
20+
def publishRequested = taskNameContains('publish') || taskRequested('install')
21+
def checkstyleRequested = taskNameContains('checkstyle')
22+
def eclipseRequested = taskNameContains('eclipse')
23+
def groovySourcePresent = project.name == 'jme3-core'
24+
25+
if (groovySourcePresent) {
26+
apply plugin: 'groovy'
27+
}
28+
29+
if (publishRequested) {
30+
apply plugin: 'maven-publish'
31+
apply plugin: 'signing'
32+
}
33+
34+
if (eclipseRequested) {
35+
apply plugin: 'eclipse'
36+
37+
eclipse.jdt.file.withProperties { props ->
38+
props.setProperty "org.eclipse.jdt.core.circularClasspath", "warning"
39+
}
40+
}
41+
42+
if (checkstyleRequested) {
43+
apply plugin: 'checkstyle'
44+
}
45+
1846
java {
1947
sourceCompatibility = JavaVersion.VERSION_1_8
2048
targetCompatibility = JavaVersion.VERSION_1_8
2149
}
2250

23-
tasks.withType(JavaCompile) { // compile-time options:
51+
tasks.withType(JavaCompile).configureEach { // compile-time options:
2452
//options.compilerArgs << '-Xlint:deprecation' // to show deprecation warnings
2553
options.compilerArgs << '-Xlint:unchecked'
2654
options.encoding = 'UTF-8'
@@ -42,8 +70,10 @@ dependencies {
4270
testImplementation libs.junit.jupiter
4371
testImplementation libs.mokito.core
4472
testImplementation libs.mokito.junit.jupiter
45-
testImplementation libs.groovy.test
4673
testRuntimeOnly libs.junit.platform.launcher
74+
if (groovySourcePresent) {
75+
testImplementation libs.groovy.test
76+
}
4777
}
4878

4979
// Uncomment if you want to see the status of every test that is run and
@@ -65,7 +95,7 @@ jar {
6595
}
6696
}
6797

68-
javadoc {
98+
tasks.named('javadoc', Javadoc) {
6999
failOnError = false
70100
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
71101
options.docTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc"
@@ -88,14 +118,18 @@ test {
88118
}
89119
}
90120

91-
task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {
121+
def sourcesJar = tasks.register('sourcesJar', Jar) {
122+
dependsOn classes
123+
description = 'Creates a jar from the source files.'
92124
archiveClassifier = 'sources'
93125
from sourceSets*.allSource
94126
}
95127

96-
task javadocJar(type: Jar, dependsOn: javadoc, description: 'Creates a jar from the javadoc files.') {
128+
def javadocJar = tasks.register('javadocJar', Jar) {
129+
dependsOn javadoc
130+
description = 'Creates a jar from the javadoc files.'
97131
archiveClassifier = 'javadoc'
98-
from javadoc.destinationDir
132+
from tasks.named('javadoc', Javadoc).map { it.destinationDir }
99133
}
100134

101135
ext.pomConfig = {
@@ -123,116 +157,120 @@ ext.pomConfig = {
123157
}
124158
}
125159

126-
tasks.named('assemble') {
127-
dependsOn sourcesJar
128-
if (buildJavaDoc == "true") {
129-
dependsOn javadocJar
130-
}
131-
}
160+
if (publishRequested) {
161+
def hasSigningKey = providers.gradleProperty('signingKey').isPresent()
162+
def publishedModuleName = "${project.name}-${jmeFullVersion}"
132163

133-
publishing {
134-
publications {
135-
maven(MavenPublication) {
136-
artifact javadocJar
137-
artifact sourcesJar
138-
from components.java
139-
pom {
140-
description = POM_DESCRIPTION
141-
developers {
142-
developer {
143-
id = 'jMonkeyEngine'
144-
name = 'jMonkeyEngine Team'
145-
}
164+
publishing {
165+
publications {
166+
maven(MavenPublication) {
167+
artifact sourcesJar
168+
if (buildJavaDoc == "true") {
169+
artifact javadocJar
146170
}
147-
inceptionYear = POM_INCEPTION_YEAR
148-
licenses {
149-
license {
150-
distribution = POM_LICENSE_DISTRIBUTION
151-
name = POM_LICENSE_NAME
152-
url = POM_LICENSE_URL
171+
from components.java
172+
pom {
173+
description = POM_DESCRIPTION
174+
developers {
175+
developer {
176+
id = 'jMonkeyEngine'
177+
name = 'jMonkeyEngine Team'
178+
}
153179
}
180+
inceptionYear = POM_INCEPTION_YEAR
181+
licenses {
182+
license {
183+
distribution = POM_LICENSE_DISTRIBUTION
184+
name = POM_LICENSE_NAME
185+
url = POM_LICENSE_URL
186+
}
187+
}
188+
name = POM_NAME
189+
scm {
190+
connection = POM_SCM_CONNECTION
191+
developerConnection = POM_SCM_DEVELOPER_CONNECTION
192+
url = POM_SCM_URL
193+
}
194+
url = POM_URL
154195
}
155-
name = POM_NAME
156-
scm {
157-
connection = POM_SCM_CONNECTION
158-
developerConnection = POM_SCM_DEVELOPER_CONNECTION
159-
url = POM_SCM_URL
160-
}
161-
url = POM_URL
196+
version = project.version
162197
}
163-
version = project.version
164198
}
165-
}
166199

167-
repositories {
168-
maven {
169-
name = 'Dist'
170-
url = gradle.rootProject.projectDir.absolutePath + '/dist/maven'
171-
}
200+
repositories {
201+
maven {
202+
name = 'Dist'
203+
url = gradle.rootProject.projectDir.absolutePath + '/dist/maven'
204+
}
172205

173-
// Uploading to Sonatype relies on the existence of 2 properties
174-
// (centralUsername and centralPassword)
175-
// which should be set using -P options on the command line.
206+
// Uploading to Sonatype relies on the existence of 2 properties
207+
// (centralUsername and centralPassword)
208+
// which should be set using -P options on the command line.
176209

177-
maven {
178-
// for uploading release builds to the default repo in Sonatype's OSSRH staging area
179-
credentials {
180-
username = gradle.rootProject.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
181-
password = gradle.rootProject.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
210+
maven {
211+
// for uploading release builds to the default repo in Sonatype's OSSRH staging area
212+
credentials {
213+
username = gradle.rootProject.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
214+
password = gradle.rootProject.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
215+
}
216+
name = 'Central'
217+
url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
182218
}
183-
name = 'Central'
184-
url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
185-
}
186-
maven {
187-
// for uploading snapshot builds to Sonatype's maven-snapshots repo
188-
credentials {
189-
username = gradle.rootProject.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
190-
password = gradle.rootProject.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
219+
maven {
220+
// for uploading snapshot builds to Sonatype's maven-snapshots repo
221+
credentials {
222+
username = gradle.rootProject.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
223+
password = gradle.rootProject.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
224+
}
225+
name = 'SNAPSHOT'
226+
url = 'https://central.sonatype.com/repository/maven-snapshots/'
191227
}
192-
name = 'SNAPSHOT'
193-
url = 'https://central.sonatype.com/repository/maven-snapshots/'
194228
}
195229
}
196-
}
197230

198-
publishToMavenLocal.doLast {
199-
println 'published ' + project.getName() + "-${jmeFullVersion} to mavenLocal"
200-
}
201-
task('install') {
202-
dependsOn 'publishToMavenLocal'
203-
}
231+
tasks.named('publishToMavenLocal') {
232+
doLast {
233+
println "published ${publishedModuleName} to mavenLocal"
234+
}
235+
}
236+
tasks.register('install') {
237+
dependsOn 'publishToMavenLocal'
238+
}
204239

205-
signing {
206-
def signingKey = gradle.rootProject.findProperty('signingKey')
207-
def signingPassword = gradle.rootProject.findProperty('signingPassword')
208-
useInMemoryPgpKeys(signingKey, signingPassword)
240+
signing {
241+
def signingKey = gradle.rootProject.findProperty('signingKey')
242+
def signingPassword = gradle.rootProject.findProperty('signingPassword')
243+
useInMemoryPgpKeys(signingKey, signingPassword)
209244

210-
sign publishing.publications.maven
211-
}
212-
tasks.withType(Sign) {
213-
onlyIf { gradle.rootProject.hasProperty('signingKey') }
245+
sign publishing.publications.maven
246+
}
247+
tasks.withType(Sign).configureEach {
248+
onlyIf { hasSigningKey }
249+
}
214250
}
215251

216-
def checkstyleSupported = JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_21)
252+
if (checkstyleRequested) {
253+
def checkstyleSupported = JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_21)
217254

218-
checkstyle {
219-
toolVersion = libs.versions.checkstyle.get()
220-
configFile = file("${gradle.rootProject.rootDir}/config/checkstyle/checkstyle.xml")
221-
}
255+
checkstyle {
256+
toolVersion = libs.versions.checkstyle.get()
257+
configFile = file("${gradle.rootProject.rootDir}/config/checkstyle/checkstyle.xml")
258+
}
222259

223-
checkstyleMain {
224-
source ='src/main/java'
225-
}
260+
checkstyleMain {
261+
source ='src/main/java'
262+
}
226263

227-
checkstyleTest {
228-
source ='src/test/java'
229-
}
264+
checkstyleTest {
265+
source ='src/test/java'
266+
}
230267

231-
tasks.withType(Checkstyle) {
232-
enabled = checkstyleSupported
233-
reports {
234-
xml.required.set(false)
235-
html.required.set(true)
268+
tasks.withType(Checkstyle).configureEach {
269+
enabled = checkstyleSupported
270+
reports {
271+
xml.required.set(false)
272+
html.required.set(true)
273+
}
274+
include("**/com/jme3/renderer/**/*.java")
236275
}
237-
include("**/com/jme3/renderer/**/*.java")
238276
}

0 commit comments

Comments
 (0)