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

Commit

Permalink
build: Improve version information
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyJones committed May 16, 2024
1 parent 84ce292 commit 598c3e6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
60 changes: 34 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import java.text.SimpleDateFormat

plugins {
id 'java-library'
id 'java-library-distribution'
id 'maven-publish'
id "com.google.protobuf" version "0.9.4"

}
group 'io.contract-testing.contractcase'
version "0.0.1" // x-release-please-version
group = 'io.contract-testing.contractcase'
version = "0.0.1" // x-release-please-version

sourceCompatibility = '17'

Expand Down Expand Up @@ -35,8 +37,6 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testImplementation 'com.google.protobuf:protobuf-gradle-plugin:0.9.4'
// api("org.junit.jupiter:junit-jupiter-api")
// compileOnly("org.junit.jupiter:junit-jupiter")
}

test {
Expand All @@ -45,6 +45,16 @@ test {

jar {
duplicatesStrategy(DuplicatesStrategy.WARN)
manifest {
attributes(
'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-Jdk': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Implementation-Version': version,
'Implementation-Title': 'ContractCase Java DSL, for defining and verifying contracts with ContractCase',
'Specification-Title': 'ContractCase Java DSL, for defining and verifying contracts with ContractCase',
'Specification-Version': version,
)
}
}

sourceSets {
Expand Down Expand Up @@ -103,30 +113,28 @@ publishing {
}
}
}
repositories {
maven {
name = "OSSRH"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
/*
contractcase(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}*/
}
repositories {
maven {
name = "OSSRH"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
mavenLocal()
}
/*
contractcase(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ class BoundaryVersionGenerator {


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

}
1 change: 0 additions & 1 deletion version.txt

This file was deleted.

0 comments on commit 598c3e6

Please sign in to comment.