plugins { id 'java' id 'maven-publish' id 'war' id "org.owasp.dependencycheck" version "6.2.2" id 'com.github.johnrengelman.shadow' version '7.0.0' id "org.sonarqube" version "3.3" } shadowJar { dependsOn(test) zip64 = true from sourceSets.main.output archiveClassifier.set('jar-with-dependencies') } group = 'myapp' version = 'TEST-SNAPSHOT' description = 'myapp' java.sourceCompatibility = JavaVersion.VERSION_11 webAppDirName = 'WebContent' repositories { mavenLocal() maven { url = uri('https://repo.maven.apache.org/maven2/') } } dependencies { My dependencies list {....} } sourceSets { main { java { srcDir 'src' } resources { srcDir 'src' } } integrationTest { compileClasspath += sourceSets.main.output + sourceSets.test.output runtimeClasspath += sourceSets.main.output } } configurations { integrationTestImplementation.extendsFrom testImplementation integrationTestRuntime.extendsFrom testRuntime } task integrationTest(type: Test) { testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath mustRunAfter test } static def getBuildNumber() { return System.getProperty("build.number") == null ? "" : System.getProperty("build.number") } war { dependsOn(test) duplicatesStrategy = DuplicatesStrategy.WARN rootSpec.exclude("test/", "integrationTest", "junit-*.jar", "mockito-*.jar", "hamcrest*.jar") manifest { attributes( "Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' '), "Build-Time": new Date().format('yyyy-MM-dd HH:mm:ss'), "Implementation-Build-Number": getBuildNumber(), ) } } def testPrintResult = { afterSuite { desc, result -> if (!desc.parent) { // will match the outermost suite println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" } } } test { configure testPrintResult useJUnitPlatform() testLogging { events "passed", "skipped", "failed" outputs.upToDateWhen {false} showStandardStreams = true } } integrationTest { configure testPrintResult useJUnitPlatform() testLogging { events "passed", "skipped", "failed" } } check.dependsOn integrationTest publishing { publications { mavenWeb(MavenPublication) { from components.web } shadow(MavenPublication) { publication -> project.shadow.component(publication) } } repositories { My repo } } task printSourceSetInformation() { doLast { sourceSets.each { srcSet -> println "[" + srcSet.name + "]" print "-->Source directories: " + srcSet.allJava.srcDirs + "\n" print "-->Output directories: " + srcSet.output.classesDirs.files + "\n" println "" } } }