Skip to content

Commit

Permalink
Add bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
ewpratten committed Jul 4, 2020
1 parent e03761d commit f8ec1cc
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Any folder containing a `build.gradle` file can be a module. Make sure to add th

To build a new release, first update the version number at the top of `build.gradle`.

Next, run `./gradlew clean buildRelease`. This will build all modules individually, then also build a packaged jar with everything in it. All files will be exported to the `_release` folder. Team members with permission to publish releases can then create a new GitHub release [here](https://github.com/frc5024/lib5k/releases/new).
Next, run `./gradlew clean build buildRelease`. This will build all modules individually, then also build a packaged jar with everything in it. All files will be exported to the `_release` folder. Team members with permission to publish releases can then create a new GitHub release [here](https://github.com/frc5024/lib5k/releases/new).

Otherwise, you can just use these files, and follow [the instructions above](#using).

Expand Down
28 changes: 19 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,24 @@ task mmJar(type: Jar, dependsOn: subprojects.jar) {
}
}

task buildRelease(type: Jar, dependsOn: subprojects.fatJar){
task buildRelease(type: Jar){
delete file("_release")
doLast{
subprojects.each { subproject ->
from subproject.configurations.archives.artifacts.files.collect {
zipTree(it)
}
}
file("$rootProject.buildDir/libs/lib5k-"+project.version+".jar").renameTo(file("_release/lib5k-"+project.version+"-monolithic.jar"))
}
delete file("$rootProject.buildDir/libs")
dependsOn subprojects.fatJar
dependsOn subprojects.jar
dependsOn project(":bundle").buildBundle
// doLast{
// subprojects.each { subproject ->
// from subproject.configurations.archives.artifacts.files.collect {
// zipTree(it)
// }
// }
// // fileTree("_release/modules").each {
// // from it
// // }

// // from fileTree("_release/modules").files.collect
// println "$rootProject.buildDir/libs/lib5k-"+project.version+".jar"
// file("$rootProject.buildDir/libs/lib5k-"+project.version+".jar").renameTo(file("_release/lib5k-"+project.version+"-monolithic.jar"))
// }
}
29 changes: 29 additions & 0 deletions bundle/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins{
id "java-library"
}

apply from: "../gradle_utils/libversions.gradle"
apply from: "../gradle_utils/simpleunittest.gradle"
apply from: "../gradle_utils/mavenrepos.gradle"

dependencies{
println "Fetching dependancies for bundle"
rootProject.subprojects.each{
if (it.name != "bundle"){
println it.name
api it
}
}
}

task buildBundle(type: Jar) {
baseName = "lib5k-bundle-" + rootProject.version + '-monolithic'
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
destinationDir = file("$rootDir/_release")
}

// This is just to remove build errors in root script
task fatJar{

}
3 changes: 2 additions & 1 deletion gradle_utils/projectjar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ task fatJar(type: Jar) {
// 'Implementation-Version': version,
// 'Main-Class': 'com.mkyong.DateUtils'
// }
// classifier = 'all'
baseName = project.name + "-" + rootProject.version + '-module-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
destinationDir = file("$rootDir/_release/modules")
}
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

rootProject.name = 'lib5k'

// Bundle build script
include ":bundle"

// Add all modules here
include ":purepursuit"
Expand Down

0 comments on commit f8ec1cc

Please sign in to comment.