Skip to content

Commit

Permalink
Gradle voodoo: build distribution zip, aggregate services jars, add s…
Browse files Browse the repository at this point in the history
…ources jar - on build
  • Loading branch information
chilimannen committed Mar 8, 2017
1 parent 1195cbd commit f61ce25
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ lib/
target/
build/
core/conf/
prototype/service
prototype/website/bower_components/
core/test/resources/Configurations/testfile.json
prototype/core-full-1.0-SNAPSHOT.jar
prototype/core-1.0-SNAPSHOT.jar
core/db/
services/logging/db/
services/logging/db/
db
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ notifications:
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
before_script:
- sleep 10
services:
# - elasticsearch - requires version 5.2.2
- mongodb
cache:
directories:
Expand All @@ -23,8 +20,9 @@ deploy:
secure: W9XJLLhuWj7f3/xcV8TYWVTrtoYi8iMQTcatwNR3I9nKmK05ywab/G+iD4anZJWyZrOtvuS0ztBrPQMiGGdEju1iMRkuFTlC0XJOAJNL60gGgeZ7ngpBV/RWEEqGcUw+CNXvVIkbox9uXK5qokw8PMB7osnjmRpyfmLIL2hbiYVzXN3S3iKGn8nO7evWIVYjhEcHcZSCMlcLviBWJgCVzBpofubTy6zOVIggRG17tJjfstDsoyjmCWoZA18ZlGftcvM1a60H5retY9k/qYYVT5EPTrDmLLAHLP7Vy2ScgfzCWcO9V9Q8/BgfEwlpQ4j7ngHWW8zIk3QCqPZ9iDiXTkok8qhMQTRKebIOXJGnaI9ZoT/WehL6mGhHW23Cvpp8ubDLSyFuv9ylfUk9drdshEP/b02dV2o3S06PYhjXFinoOBRXMkIHwX0QFt8W85OyOCjARpBR5qDyxH5gCxSpfFaoUG0/CdWWoKdXDlwaG3KNzyU2jsjGsI3Y73q2AE+9qc9tgHHheK2TIjJPRMkjy0bxRHmEnSMM3JsP+/vNJNEDnZFgMxpHcixMikVbxpBzcSFSnjQNZs1bETMaHmIsPX34w8ODwwd5XQCrZb0zJiqe8A7tlcjcY9izTJ7+2O2hl9Lq8DJCQNb0awWXbX+KYjHH9YG2eF5sXxPrLLWgX+k=
file_glob: true
file:
- release/*
- build/distributions/*
- services/build/libs/*
- core/build/libs/*
skip_cleanup: true
overwrite: true
on:
Expand Down
16 changes: 3 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ subprojects {
apply plugin: 'idea'

version = rootProject.version
group = rootProject.version
group = rootProject.group

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down Expand Up @@ -46,14 +46,9 @@ subprojects {
exceptionFormat "full"
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
}

task archiveZip(type: Zip, dependsOn: 'jar') {
task archiveZip(type: Zip) {
baseName = 'prototype'
from fileTree('prototype')

Expand All @@ -62,12 +57,7 @@ task archiveZip(type: Zip, dependsOn: 'jar') {
}
}

task copyTask(type: Copy, dependsOn: 'build') {
from (subprojects.collect {it.tasks.withType(Jar)})
/*from (subprojects.collect {it.tasks.withType(Javadoc)})*/
from (subprojects.collect {it.tasks.withType(AbstractArchiveTask)})
destinationDir = new File('release')
}
build.dependsOn archiveZip

if (System.env.TRAVIS == 'true') {
allprojects {
Expand Down
7 changes: 6 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
task sourcesJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allSource
}

jar {
from {
(configurations.runtime).collect {
Expand All @@ -9,7 +14,7 @@ jar {
'Implementation-Version': version,
'Main-Class': 'com.codingchili.core.Launcher'
}
}
}.dependsOn sourcesJar

dependencies {
compile group: 'junit', name: 'junit', version: '4.12'
Expand Down
24 changes: 23 additions & 1 deletion services/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,26 @@ subprojects {
compile project(':core')
compile project(':common')
}
}
}

subprojects.each { subproject -> evaluationDependsOn(subproject.path) }

task sourcesJar(type: Jar, dependsOn: subprojects.build) {
classifier 'sources'
subprojects.each { subproject ->
from subproject.sourceSets.main.allSource
}
}

task allJar(type: Jar, dependsOn: sourcesJar) {
baseName = 'services'
subprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
}
}

jar {
actions = []
}.dependsOn allJar

0 comments on commit f61ce25

Please sign in to comment.