diff --git a/apps/ministreaming/build.gradle b/apps/ministreaming/build.gradle index e3c4351c5b..6eb49bb3ad 100644 --- a/apps/ministreaming/build.gradle +++ b/apps/ministreaming/build.gradle @@ -21,6 +21,13 @@ dependencies { api project(':core') } +jar { + manifest { + attributes 'Specification-Title': 'I2P Streaming API' + attributes 'Implementation-Title': 'I2P Java Streaming API' + } +} + configurations { tests } diff --git a/apps/streaming/build.gradle b/apps/streaming/build.gradle index 2772ad66be..c1fc1ead4b 100644 --- a/apps/streaming/build.gradle +++ b/apps/streaming/build.gradle @@ -23,3 +23,10 @@ dependencies { api project(':apps:ministreaming') testImplementation project(path: ':apps:ministreaming', configuration: 'tests') } + +jar { + manifest { + attributes 'Specification-Title': 'I2P Streaming Implementation' + attributes 'Implementation-Title': 'I2P Java Streaming Implementation' + } +} diff --git a/build.gradle b/build.gradle index 94bda0ea45..2bfda4b21b 100644 --- a/build.gradle +++ b/build.gradle @@ -32,6 +32,34 @@ String getBuildExtra() { 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) { if (src.contains('.')) { src.substring(src.lastIndexOf('.') + 1) @@ -54,6 +82,9 @@ def buildVersion = getBuildVersion() def buildExtra = getBuildExtra() def fullVersion = "$releaseVersion-$buildVersion$buildExtra" +def builtBy = getBuiltBy() +def workspaceVersion = getWorkspaceVersion() + // Exclude apps/ dir itself, but include its subdirs def javaProjects = subprojects - project(':apps') @@ -73,15 +104,28 @@ configure(javaProjects) { testCompile 'org.mockito:mockito-core:2.11.0' } - jar { - manifest { - attributes 'Implementation-Version': "$fullVersion" - } - } - sourceCompatibility = 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) { preserveFileTimestamps = false reproducibleFileOrder = true diff --git a/core/build.gradle b/core/build.gradle index a7533d2ad2..ba0469ca35 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -71,6 +71,14 @@ if (System.getenv("TARGET_JAVA_HOME") == null && JavaVersion.current() != JavaVe 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 { tests } diff --git a/history.txt b/history.txt index 38ce6c559e..44e55f3bcd 100644 --- a/history.txt +++ b/history.txt @@ -2,6 +2,7 @@ * Gradle: - Adjust dependencies to match Tomcat and Jetty updates - Generate reproducible archives + - Generate attributes for JAR manifests 2019-04-17 zzz * Transport: More fixes for NTCP when SSU disabled (ticket #1417) diff --git a/router/build.gradle b/router/build.gradle index 0ea245c22d..7e73d59b93 100644 --- a/router/build.gradle +++ b/router/build.gradle @@ -28,6 +28,9 @@ dependencies { jar { 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 attributes 'Class-Path': 'jetty-i2p.jar jetty-java5-threadpool.jar jetty-rewrite-handler.jar jetty-sslengine.jar jetty-start.jar jetty-util.jar' }