Skip to content

Commit

Permalink
Optimize gradle file structure
Browse files Browse the repository at this point in the history
See also: #65
  • Loading branch information
Benedikt Stemmildt committed Feb 27, 2017
1 parent da5bd2d commit 22925ea
Show file tree
Hide file tree
Showing 24 changed files with 280 additions and 221 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ out
*.iws
*.iml
*.ipr
gradle*

testsupport/testsupport.iml
status/status.iml
Expand Down
133 changes: 14 additions & 119 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'jacoco'

buildscript {
apply from: 'dependencies.gradle'
apply from: "${rootDir}/gradle/dependencies.gradle"

repositories {
maven { url 'http://repo.spring.io/libs-snapshot' }
Expand All @@ -13,9 +8,7 @@ buildscript {
}

dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:' + springBootVersion)
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.14.0'
classpath gradle_plugins.values()
}
}

Expand All @@ -26,53 +19,20 @@ configure(allprojects) {
apply plugin: 'propdeps-eclipse'
}

dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'b', 'rc', 'cr', 'm', 'ea', 'incubating', 'atlassian', 'snap'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\w\d-]*/
}
if (rejected) {
selection.reject("Ignore due to beta/alpha pattern: ${selection.candidate}")
}
if (selection.candidate.group == 'org.mockito' && selection.candidate.module == 'mockito-core' && selection.candidate.version != '1.10.19') {
selection.reject('Can not update mockito to current release because of spring is still depending on 1.x version.')
}
}
}
}

repositories {
mavenCentral()
maven { url 'http://repo.spring.io/libs-snapshot' }
}

idea {
project {
languageLevel = '1.8'
ipr.withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
}
}
}

eclipse {
classpath {
//customizing the classes output directory:
defaultOutputDir = file('build/bin')

//default settings for downloading sources and Javadoc:
downloadSources = true
downloadJavadoc = false
}
}
apply from: "${rootDir}/gradle/root/versions.gradle"
apply from: "${rootDir}/gradle/root/idea.gradle"
apply from: "${rootDir}/gradle/root/eclipse.gradle"
apply from: "${rootDir}/gradle/root/jacoco.gradle"

subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'jacoco'
apply plugin: 'project-report'
apply plugin: 'signing'

Expand All @@ -93,41 +53,17 @@ subprojects {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}

ext['thymeleaf.version'] = versions.thymeleaf
ext['thymeleaf-layout-dialect.version'] = versions.thymeleaf_layout_dialect

dependencies {
optional 'org.springframework.boot:spring-boot-configuration-processor:' + springBootVersion
optional libraries.spring_boot_configuration_processor
}

compileJava.dependsOn(processResources)

jar {
manifest.attributes provider: 'gradle'
}

jacoco {
toolVersion = '0.7.9'
}

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}

test {
// pass -Dspring.profiles.active=local and other system properties to the test task
systemProperties = System.properties
// jacoco needs this property when using it with subprojects
systemProperties['user.dir'] = workingDir

afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
println "Test Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
}
}
}
test.finalizedBy jacocoTestReport

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
Expand All @@ -140,49 +76,8 @@ subprojects {

task allDeps(type: DependencyReportTask) {}

idea {
module {
iml {
withXml {
def moduleRoot = it.asNode()
def facetManager = moduleRoot.component.find { component -> component.'@name' == 'FacetManager' }
if (!facetManager) {
facetManager = moduleRoot.appendNode('component', [name: 'FacetManager'])
}

def springFacet = facetManager.facet.find { facet -> facet.'@type' == 'Spring' && facet.'@name' == 'Spring' }
if (!springFacet) {
springFacet = facetManager.appendNode('facet', [type: 'Spring', name: 'Spring'])
springFacet.appendNode('configuration')
}
}
}
}
}
}

def publishedProjects = subprojects.findAll { (!it.projectDir.name.contains('example')) }

task jacocoMerge(type: JacocoMerge) {
publishedProjects.each { subproject ->
executionData subproject.tasks.withType(Test)
}
}

task jacocoRootReport(type: JacocoReport) {
dependsOn jacocoMerge

additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(publishedProjects.sourceSets.main.output)
executionData jacocoMerge.destinationFile

reports {
html.enabled = true
xml.enabled = true
}

doFirst {
executionData = files(executionData.findAll { it.exists() })
}
apply from: "${rootDir}/gradle/idea.gradle"
apply from: "${rootDir}/gradle/compile.gradle"
apply from: "${rootDir}/gradle/test.gradle"
apply from: "${rootDir}/gradle/jacoco.gradle"
}
60 changes: 0 additions & 60 deletions dependencies.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion edison-cache/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
compile project(":edison-core")
compile libs.caffeine
compile libraries.caffeine

testCompile project(":edison-testsupport")
}
Expand Down
28 changes: 17 additions & 11 deletions edison-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
dependencies {
compileOnly libs.asyncHttp
compileOnly libraries.async_http_client

compile libs.springBootWeb
compile libs.springBootThymeleaf
compile libs.thymeleaf3
compile libs.jcip
compile libs.logging
compile libs.metrics
compile libs.metricsSpring
compile libraries.spring_boot_starter_web
compile libraries.spring_boot_starter_actuator
compile libraries.spring_boot_starter_thymeleaf
compile libraries.thymeleaf
compile libraries.thymeleaf_spring4
compile libraries.thymeleaf_layout_dialect
compile libraries.jcip_annotations
compile libraries.logback_classic
compile libraries.metrics_annotation
compile libraries.metrics_core
compile libraries.metrics_graphite
compile libraries.metrics_healthchecks
compile libraries.metrics_jvm
compile libraries.metrics_spring
compile libraries.spring_context_support

testCompile project(":edison-testsupport")
testCompile libs.testUnit
testCompile libs.asyncHttp

testCompile libraries.async_http_client
}

artifacts {
Expand Down
7 changes: 3 additions & 4 deletions edison-jobs/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
dependencies {
compileOnly libs.asyncHttp
compileOnly libraries.async_http_client

compile project(":edison-core")

testCompile project(":edison-testsupport")
testCompile libs.jaywayJsonPath
testCompile libs.testUnit
testCompile libs.skyscreamer
testCompile test_libraries.json_path
testCompile test_libraries.jsonassert
}

artifacts {
Expand Down
9 changes: 4 additions & 5 deletions edison-mongo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ dependencies {
compileOnly project(":edison-togglz")

compile project(":edison-core")
compile libs.springBoot
compile libs.logging
compile libs.jcip
compile libs.mongoDb
compile libraries.spring_boot
compile libraries.spring_boot_autoconfigure
compile libraries.mongodb_driver

testCompile project(":edison-testsupport")
testCompile project(":edison-jobs")
testCompile project(":edison-togglz")
testCompile libs.fakeMongo
testCompile test_libraries.fongo
}

artifacts {
Expand Down
16 changes: 12 additions & 4 deletions edison-testsupport/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
dependencies {
compileOnly libs.togglz
compileOnly libs.testTogglz
compileOnly libraries.togglz_servlet
compileOnly libraries.togglz_console
compileOnly libraries.togglz_spring_web
compileOnly test_libraries.togglz_testing

compile libs.springBoot
compile libs.testUnit
compile libraries.spring_boot
compile libraries.spring_boot_autoconfigure
compile test_libraries.junit
compile test_libraries.hamcrest_core
compile test_libraries.hamcrest_library
compile test_libraries.mockito_core
compile test_libraries.spring_test
compile test_libraries.spring_boot_starter_test
}

artifacts {
Expand Down
10 changes: 4 additions & 6 deletions edison-togglz/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
dependencies {
compile project(":edison-core")
compile libs.springBootWeb
compile libs.logging
compile libs.togglz
compile libs.jcip
compile 'com.unboundid:unboundid-ldapsdk-minimal-edition:3.2.1'
compile libraries.togglz_servlet
compile libraries.togglz_console
compile libraries.togglz_spring_web
compile libraries.unboundid_ldapsdk_minimal_edition

testCompile libs.testUnit
testCompile project(":edison-testsupport")
}

Expand Down
4 changes: 2 additions & 2 deletions examples/example-jobs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ apply plugin: 'org.springframework.boot'
dependencies {
compile project(":edison-jobs")
// compile project(":edison-mongo") // Enable to get persistent job information
// compile libs.fakeMongo // In-Memory impl of MongoDB; not intended for production
compile libs.asyncHttp
// compile test_libraries.fongo // In-Memory impl of MongoDB; not intended for production
compile libraries.async_http_client

testCompile project(":edison-testsupport")
}
Expand Down
2 changes: 1 addition & 1 deletion examples/example-status/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'org.springframework.boot'

dependencies {
compile project(":edison-core")
compile libs.springBootDev
compile libraries.spring_boot_devtools

testCompile project(":edison-testsupport")
}
Expand Down
2 changes: 1 addition & 1 deletion examples/example-togglz-mongo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'org.springframework.boot'
dependencies {
compile project(":edison-togglz")
compile project(":edison-mongo")
compile libs.fakeMongo // In-Memory impl of MongoDB; not intended for production
compile test_libraries.fongo // In-Memory impl of MongoDB; not intended for production

testCompile project(":edison-testsupport")
}
Expand Down
Loading

0 comments on commit 22925ea

Please sign in to comment.