Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 598c3e6

Browse files
committed
build: Improve version information
1 parent 84ce292 commit 598c3e6

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

build.gradle

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import java.text.SimpleDateFormat
2+
13
plugins {
24
id 'java-library'
35
id 'java-library-distribution'
46
id 'maven-publish'
57
id "com.google.protobuf" version "0.9.4"
68

79
}
8-
group 'io.contract-testing.contractcase'
9-
version "0.0.1" // x-release-please-version
10+
group = 'io.contract-testing.contractcase'
11+
version = "0.0.1" // x-release-please-version
1012

1113
sourceCompatibility = '17'
1214

@@ -35,8 +37,6 @@ dependencies {
3537
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
3638
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
3739
testImplementation 'com.google.protobuf:protobuf-gradle-plugin:0.9.4'
38-
// api("org.junit.jupiter:junit-jupiter-api")
39-
// compileOnly("org.junit.jupiter:junit-jupiter")
4040
}
4141

4242
test {
@@ -45,6 +45,16 @@ test {
4545

4646
jar {
4747
duplicatesStrategy(DuplicatesStrategy.WARN)
48+
manifest {
49+
attributes(
50+
'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
51+
'Build-Jdk': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
52+
'Implementation-Version': version,
53+
'Implementation-Title': 'ContractCase Java DSL, for defining and verifying contracts with ContractCase',
54+
'Specification-Title': 'ContractCase Java DSL, for defining and verifying contracts with ContractCase',
55+
'Specification-Version': version,
56+
)
57+
}
4858
}
4959

5060
sourceSets {
@@ -103,30 +113,28 @@ publishing {
103113
}
104114
}
105115
}
106-
repositories {
107-
maven {
108-
name = "OSSRH"
109-
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
110-
credentials {
111-
username = System.getenv("MAVEN_USERNAME")
112-
password = System.getenv("MAVEN_PASSWORD")
113-
}
114-
}
115-
}
116-
/*
117-
contractcase(MavenPublication) {
118-
from components.java
119-
versionMapping {
120-
usage('java-api') {
121-
fromResolutionOf('runtimeClasspath')
122-
}
123-
usage('java-runtime') {
124-
fromResolutionResult()
125-
}
126-
}
127-
}*/
128116
}
129117
repositories {
118+
maven {
119+
name = "OSSRH"
120+
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
121+
credentials {
122+
username = System.getenv("MAVEN_USERNAME")
123+
password = System.getenv("MAVEN_PASSWORD")
124+
}
125+
}
130126
mavenLocal()
131127
}
128+
/*
129+
contractcase(MavenPublication) {
130+
from components.java
131+
versionMapping {
132+
usage('java-api') {
133+
fromResolutionOf('runtimeClasspath')
134+
}
135+
usage('java-runtime') {
136+
fromResolutionResult()
137+
}
138+
}
139+
}*/
132140
}

src/main/java/io/contract_testing/contractcase/BoundaryVersionGenerator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ class BoundaryVersionGenerator {
66

77

88
List<String> getVersions() {
9-
var version = getClass().getPackage().getImplementationVersion();
10-
return List.of("Java-DSL@" + (version != null ? version : "UNKNOWN"));
9+
var version = this.getClass()
10+
.getClassLoader()
11+
.getDefinedPackage("io.contract_testing.contractcase")
12+
.getImplementationVersion();
13+
return List.of("Java-DSL@" + (version != null ? version : "unknown"));
1114
}
1215

1316
}

version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)