From f61ce25cff7f568aadee6744b4b643c26847cb6b Mon Sep 17 00:00:00 2001 From: chilimannen Date: Wed, 8 Mar 2017 06:33:54 +0100 Subject: [PATCH] Gradle voodoo: build distribution zip, aggregate services jars, add sources jar - on build --- .gitignore | 7 +++---- .travis.yml | 6 ++---- build.gradle | 16 +++------------- core/build.gradle | 7 ++++++- services/build.gradle | 24 +++++++++++++++++++++++- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 4086ce22..0bbdc615 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ \ No newline at end of file +services/logging/db/ +db \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index f71683de..5419118d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: @@ -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: diff --git a/build.gradle b/build.gradle index 5adc64e3..ea4d63cb 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ subprojects { apply plugin: 'idea' version = rootProject.version - group = rootProject.version + group = rootProject.group sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -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') @@ -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 { diff --git a/core/build.gradle b/core/build.gradle index 172d47e0..11e85052 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,3 +1,8 @@ +task sourcesJar(type: Jar) { + classifier 'sources' + from sourceSets.main.allSource +} + jar { from { (configurations.runtime).collect { @@ -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' diff --git a/services/build.gradle b/services/build.gradle index 679d28c4..7d395817 100644 --- a/services/build.gradle +++ b/services/build.gradle @@ -3,4 +3,26 @@ subprojects { compile project(':core') compile project(':common') } -} \ No newline at end of file +} + +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 \ No newline at end of file