apply plugin: 'checkstyle' apply plugin: 'eclipse' apply plugin: 'findbugs' apply plugin: 'java' apply plugin: 'jacoco' apply plugin: 'pmd' apply plugin: 'maven' apply plugin: 'signing' ext.configDir = new File(projectDir, 'config') sourceCompatibility = 1.8 sourceSets { integrationTest { java.srcDir file('src/integration/java') compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.testRuntime runtimeClasspath = output + compileClasspath } } task utilsTestJar(type: Jar) { from sourceSets.test.output } dependencies { compile libs.gson // required for plugin compile libs.bouncy_castle compile libs.commons_cli compile libs.commons_codec compile libs.commons_csv compile libs.commons_exec compile libs.commons_io compile libs.commons_lang compile libs.commons_valid compile libs.hibernate compile libs.hikari compile libs.jackson compile libs.jadira_usertype compile libs.joda_time compile libs.log4j2 compile libs.mariadb compile libs.pci_ids compile libs.reflections compile libs.guava compile libs.spring_core compile libs.spring_retry compile libs.minimal_json compile 'org.jboss.logging:jboss-logging:3.2.0.Final' compile 'org.apache.commons:commons-text:1.10.0' // add spring plugin, but do not pull transitive dependencies (causes conflicts) compile(libs.spring_plugin) { exclude group: "org.springframework" } compileOnly libs.checkstyle compileOnly libs.findbugs runtime fileTree(dir: 'build/plugins', include: ['*.jar']) testCompile libs.spring_test testCompile libs.hsqldb testCompile libs.jcommander testCompile libs.mockito testCompile libs.powermock testCompile libs.testng testCompile libs.checkstyle testCompile libs.findbugs testCompile libs.commons_lang } task generateXjcLibrary(type:Exec) { workingDir 'config' commandLine './genXjcLibrary.sh' } compileJava.dependsOn generateXjcLibrary task importBaseline(type:JavaExec) { description 'Imports Baselines into the database' main = "hirs.persist.ImportCLI" if (project.hasProperty("mainArgs") ) { args mainArgs.split() } classpath = sourceSets.main.runtimeClasspath } task integrationTest(type: Test) { testClassesDir = sourceSets.integrationTest.output.classesDir classpath = sourceSets.integrationTest.runtimeClasspath } ext.checkstyleConfigDir = "$configDir/checkstyle" checkstyle { toolVersion = '8.45.1' configFile = checkstyleConfigFile configProperties.put('basedir', checkstyleConfigDir) ignoreFailures = false showViolations = true } ext.findbugsConfigDir = "$configDir/findbugs" findbugs { toolVersion = '3.0.0' ignoreFailures = false effort = 'max' excludeFilter = new File(findbugsConfigDir, 'suppressions.xml') } pmdMain { exclude '**/xjc/**' } jacocoTestReport { reports { xml.enabled true csv.enabled true html.enabled true html.destination "${buildDir}/reports/jacoco/html" } } publishing { publications { maven(MavenPublication) { artifactId 'hirs-utils' from components.java } testResources(MavenPublication) { artifactId 'hirs-utils-test' artifact utilsTestJar } } } // Maven packaging and signing group = 'io.github.nsacyber.hirs' version = '2.2.0' project.gradle.taskGraph.whenReady { graph -> project.tasks.findAll().forEach { task -> if (task.name.contains("signArchives") || task.name.contains("uploadArchives")) { // If this is set to true, the signing and maven // properties in gradle.properties must be set. task.enabled = false } } } tasks.withType(Javadoc) { failOnError false } task javadocJar(type: Jar) { classifier = 'javadoc' from javadoc } task sourcesJar(type: Jar) { classifier = 'sources' from sourceSets.main.allSource } artifacts { archives javadocJar, sourcesJar } signing { sign configurations.archives } uploadArchives { repositories { mavenDeployer { pom.project { name 'HIRS_Utils' packaging 'jar' // optionally artifactId can be defined here description 'Core utilities for the HIRS ACA.' url 'https://github.com/nsacyber/hirs' scm { connection 'scm:git:git://github.com:nsacyber/hirs.git' developerConnection 'scm:git:git://github.com:nsacyber/hirs.git' url 'https://github.com/nsacyber/hirs' } licenses { license { name 'The Apache Software License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' distribution 'repo' } } developers { developer { id 'iadgovuser29' name 'iadgovuser29' email '33426478+iadgovuser29@users.noreply.github.com' organization 'NSA Cybersecurity Directorate' organizationUrl 'https://github.com/nsacyber' } } } beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } repository(url: "https://${sonatypeDomain}/service/local/staging/deploy/maven2/") { authentication(userName: ossrhUsername, password: ossrhPassword) } snapshotRepository(url: "https://${sonatypeDomain}/content/repositories/snapshots/") { authentication(userName: ossrhUsername, password: ossrhPassword) } } } }