Gradle: Generate attributes for JAR manifests

This commit is contained in:
str4d
2019-04-21 21:01:28 +00:00
parent 967dde4395
commit 1cc330ba66
6 changed files with 76 additions and 6 deletions

View File

@ -21,6 +21,13 @@ dependencies {
api project(':core') api project(':core')
} }
jar {
manifest {
attributes 'Specification-Title': 'I2P Streaming API'
attributes 'Implementation-Title': 'I2P Java Streaming API'
}
}
configurations { configurations {
tests tests
} }

View File

@ -23,3 +23,10 @@ dependencies {
api project(':apps:ministreaming') api project(':apps:ministreaming')
testImplementation project(path: ':apps:ministreaming', configuration: 'tests') testImplementation project(path: ':apps:ministreaming', configuration: 'tests')
} }
jar {
manifest {
attributes 'Specification-Title': 'I2P Streaming Implementation'
attributes 'Implementation-Title': 'I2P Java Streaming Implementation'
}
}

View File

@ -32,6 +32,34 @@ String getBuildExtra() {
buildExtra buildExtra
} }
String getBuiltBy() {
def builtBy
file("override.properties").readLines().findAll({ line ->
line.contains("build.built-by")
}).first().eachMatch('.*=(.*)', {
builtBy = it[1]
})
builtBy
}
boolean haveMonotone() {
file("_MTN").exists()
}
String getWorkspaceVersion() {
if (haveMonotone()) {
def stdout = new ByteArrayOutputStream()
exec {
executable 'mtn'
args 'automate', 'get_base_revision_id'
standardOutput = stdout
}
stdout.toString().trim()
} else {
'unknown'
}
}
String compat(String src) { String compat(String src) {
if (src.contains('.')) { if (src.contains('.')) {
src.substring(src.lastIndexOf('.') + 1) src.substring(src.lastIndexOf('.') + 1)
@ -54,6 +82,9 @@ def buildVersion = getBuildVersion()
def buildExtra = getBuildExtra() def buildExtra = getBuildExtra()
def fullVersion = "$releaseVersion-$buildVersion$buildExtra" def fullVersion = "$releaseVersion-$buildVersion$buildExtra"
def builtBy = getBuiltBy()
def workspaceVersion = getWorkspaceVersion()
// Exclude apps/ dir itself, but include its subdirs // Exclude apps/ dir itself, but include its subdirs
def javaProjects = subprojects - project(':apps') def javaProjects = subprojects - project(':apps')
@ -73,15 +104,28 @@ configure(javaProjects) {
testCompile 'org.mockito:mockito-core:2.11.0' testCompile 'org.mockito:mockito-core:2.11.0'
} }
jar {
manifest {
attributes 'Implementation-Version': "$fullVersion"
}
}
sourceCompatibility = 1.7 sourceCompatibility = 1.7
targetCompatibility = 1.7 targetCompatibility = 1.7
jar {
// Empty attributes are set by each project. They are initialized
// here in order to create a defined ordering of the attributes.
manifest {
attributes 'Specification-Title': ''
attributes 'Specification-Version': "$releaseVersion"
attributes 'Specification-Vendor': 'The I2P Project https://geti2p.net/'
attributes 'Implementation-Title': ''
attributes 'Implementation-Version': "$fullVersion"
attributes 'Implementation-Vendor': 'The I2P Project https://geti2p.net/'
attributes 'Built-By': "$builtBy"
attributes 'Build-Date': 'reproducible'
attributes 'Base-Revision': "$workspaceVersion"
attributes 'Workspace-Changes': ''
attributes 'X-Compile-Source-JDK': "$sourceCompatibility"
attributes 'X-Compile-Target-JDK': "$targetCompatibility"
}
}
tasks.withType(AbstractArchiveTask) { tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false preserveFileTimestamps = false
reproducibleFileOrder = true reproducibleFileOrder = true

View File

@ -71,6 +71,14 @@ if (System.getenv("TARGET_JAVA_HOME") == null && JavaVersion.current() != JavaVe
test.dependsOn scalaTest test.dependsOn scalaTest
} }
jar {
manifest {
attributes 'Specification-Title': 'I2P Core API'
attributes 'Implementation-Title': 'I2P Java Core API'
attributes 'Main-Class': 'net.i2p.util.CommandLine'
}
}
configurations { configurations {
tests tests
} }

View File

@ -2,6 +2,7 @@
* Gradle: * Gradle:
- Adjust dependencies to match Tomcat and Jetty updates - Adjust dependencies to match Tomcat and Jetty updates
- Generate reproducible archives - Generate reproducible archives
- Generate attributes for JAR manifests
2019-04-17 zzz 2019-04-17 zzz
* Transport: More fixes for NTCP when SSU disabled (ticket #1417) * Transport: More fixes for NTCP when SSU disabled (ticket #1417)

View File

@ -28,6 +28,9 @@ dependencies {
jar { jar {
manifest { manifest {
attributes 'Specification-Title': 'I2P Router'
attributes 'Implementation-Title': 'I2P Java Router'
attributes 'Main-Class': 'net.i2p.router.CommandLine'
// so people with very old wrapper.config files will still work with Jetty 6 // so people with very old wrapper.config files will still work with Jetty 6
attributes 'Class-Path': 'jetty-i2p.jar jetty-java5-threadpool.jar jetty-rewrite-handler.jar jetty-sslengine.jar jetty-start.jar jetty-util.jar' attributes 'Class-Path': 'jetty-i2p.jar jetty-java5-threadpool.jar jetty-rewrite-handler.jar jetty-sslengine.jar jetty-start.jar jetty-util.jar'
} }