From 7365d3893a12813604b2ef1fc1f61f1432bd37a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jo=C3=B1ski?= Date: Sun, 11 Sep 2016 13:08:46 +0200 Subject: [PATCH] #69. Created manifest generation. Added publish task --- build.gradle | 68 ++++++++++++++++--- gradle.properties | 4 ++ settings.gradle | 1 - .../NotEqualHashCodeAssertionErrorTest.java | 2 +- 4 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 gradle.properties diff --git a/build.gradle b/build.gradle index 6966c34c..0956a189 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,7 @@ +import java.time.ZoneOffset +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter + ext { JUNIT_JUPITER_VERSION = "5.0.0-SNAPSHOT" JUNIT_PLATFORM_VERSION = "1.0.0-SNAPSHOT" @@ -14,17 +18,12 @@ buildscript { } } - -group 'pojo-tester' -version '0.1.0' - apply plugin: 'java' apply plugin: 'idea' apply plugin: 'jacoco' apply plugin: 'info.solidsoft.pitest' apply plugin: 'org.junit.platform.gradle.plugin' - -sourceCompatibility = 1.8 +apply plugin: 'maven-publish' repositories { mavenCentral() @@ -81,9 +80,60 @@ pitest { outputFormats = ['XML', 'HTML'] } -jacocoTestReport.mustRunAfter(test) -check.dependsOn jacocoTestReport - task wrapper(type: Wrapper) { gradleVersion = '3.0' } + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } +} + +publishing.publications.all { + pom.withXml { + asNode().dependencies.'*'.findAll() { + it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep -> + dep.name == it.artifactId.text() + } + }.each { it.scope*.value = 'compile' } + } +} + +jar { + manifest.attributes(createManifestAttributes()) +} + +def createManifestAttributes() { + Map attributes = new HashMap<>(); + attributes.put('Manifest-Version', 1.0,) + attributes.put('Implementation-Title', rootProject.name,) + attributes.put('Implementation-Version', version,) + attributes.put('Implementation-Vendor', 'pojo.pl',) + attributes.put('Created-By', System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')',) + attributes.put('Built-With', "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}",) + attributes.put('Build-Time', ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_ZONED_DATE_TIME),) + attributes.put('Built-By', gitUser()) + attributes +} + + +static def gitUser() { + def username = "" + def useremail = "" + + def userNameProc = "git config user.name".execute() + userNameProc.in.eachLine { line -> username = line } + userNameProc.waitFor() + + def userEmailProc = "git config user.email".execute() + userEmailProc.in.eachLine { line -> useremail = line } + userEmailProc.waitFor() + username + " " + useremail +} + +check.dependsOn jacocoTestReport +build.dependsOn publishToMavenLocal + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..4bb57297 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +group=org.pojo +artifact=pojo-tester +version=0.1.0 +sourceCompatibility=1.8 diff --git a/settings.gradle b/settings.gradle index c021e27c..4ed867cf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1 @@ rootProject.name = 'pojo-tester' - diff --git a/src/test/java/org/pojo/tester/assertion/hashcode/NotEqualHashCodeAssertionErrorTest.java b/src/test/java/org/pojo/tester/assertion/hashcode/NotEqualHashCodeAssertionErrorTest.java index e76b603a..2a290a70 100644 --- a/src/test/java/org/pojo/tester/assertion/hashcode/NotEqualHashCodeAssertionErrorTest.java +++ b/src/test/java/org/pojo/tester/assertion/hashcode/NotEqualHashCodeAssertionErrorTest.java @@ -18,7 +18,7 @@ public void Should_Return_Expected_Detailed_Message() { + "testedObject\n" + "and\n" + "otherObject\n" - + "have should have different hash codes:\n" + + "should have different hash codes:\n" + "1\n" + "and\n" + "2";