From a16f4d25dc086922d743426a363b987c04acad81 Mon Sep 17 00:00:00 2001 From: Jerry Mao Date: Mon, 9 Jan 2023 15:33:15 +1100 Subject: [PATCH] Ensure source code is released by buildsystem --- build.gradle | 19 ++++++++++++++++--- engine/build.gradle | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 3402ce63..9ed9cffb 100644 --- a/build.gradle +++ b/build.gradle @@ -91,7 +91,7 @@ task runClient { } } -task release(dependsOn: ['release_main', 'release_docs']) +task release(dependsOn: ['release_main', 'release_docs', 'release_sources']) task release_main(type: Jar, dependsOn: [':engine:build']) { File f_version = new File(project.projectDir, "battlecode_version"); @@ -105,7 +105,7 @@ task release_main(type: Jar, dependsOn: [':engine:build']) { archiveBaseName = "battlecode"; if (project.hasProperty("release_version")) - version = project.property("release_version"); + archiveVersion = project.property("release_version"); destinationDirectory = project.projectDir; FileCollection src = files(f_version); @@ -126,12 +126,21 @@ task release_docs(type: Jar, dependsOn: [':engine:javadoc']) { archiveBaseName = "battlecode-javadoc" if (project.hasProperty("release_version")) - version = project.property("release_version"); + archiveVersion = project.property("release_version"); destinationDirectory = project.projectDir; from new File(project(":engine").docsDir, "javadoc") } +task release_sources(type: Jar, dependsOn: classes) { + archiveBaseName = "battlecode-source" + if (project.hasProperty("release_version")) + archiveVersion = project.property("release_version"); + destinationDirectory = project.projectDir; + + from project(":engine").sourceSets.main.allSource +} + task prodClient { doLast { exec { @@ -178,6 +187,10 @@ publishing { artifact release_docs { classifier 'javadoc' } + + artifact release_sources { + classifier 'sources' + } } clientWin(MavenPublication) { diff --git a/engine/build.gradle b/engine/build.gradle index 837f68fd..93a04b08 100644 --- a/engine/build.gradle +++ b/engine/build.gradle @@ -5,14 +5,18 @@ sourceCompatibility = 1.8 sourceSets { main { java.srcDirs = ["src/main"] + java.includes = ["**/*.java"] resources.srcDirs = ["src/main"] + resources.excludes = ["**/*.java"] java.destinationDirectory.set(file("$buildDir/classes")) output.resourcesDir = "$buildDir/classes" } test { java.srcDirs = ["src/test"] + java.includes = ["**/*.java"] resources.srcDirs = ["src/test"] + resources.excludes = ["**/*.java"] java.destinationDirectory.set(file("$buildDir/tests")) output.resourcesDir = "$buildDir/tests"