Changeset 1cc330b for build.gradle


Ignore:
Timestamp:
Apr 21, 2019 9:01:28 PM (19 months ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
9e0934f
Parents:
967dde4
Message:

Gradle: Generate attributes for JAR manifests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • build.gradle

    r967dde4 r1cc330b  
    3333}
    3434
     35String getBuiltBy() {
     36    def builtBy
     37    file("override.properties").readLines().findAll({ line ->
     38        line.contains("build.built-by")
     39    }).first().eachMatch('.*=(.*)', {
     40        builtBy = it[1]
     41    })
     42    builtBy
     43}
     44
     45boolean haveMonotone() {
     46    file("_MTN").exists()
     47}
     48
     49String getWorkspaceVersion() {
     50    if (haveMonotone()) {
     51        def stdout = new ByteArrayOutputStream()
     52        exec {
     53            executable 'mtn'
     54            args 'automate', 'get_base_revision_id'
     55            standardOutput = stdout
     56        }
     57        stdout.toString().trim()
     58    } else {
     59        'unknown'
     60    }
     61}
     62
    3563String compat(String src) {
    3664    if (src.contains('.')) {
     
    5583def fullVersion = "$releaseVersion-$buildVersion$buildExtra"
    5684
     85def builtBy = getBuiltBy()
     86def workspaceVersion = getWorkspaceVersion()
     87
    5788// Exclude apps/ dir itself, but include its subdirs
    5889def javaProjects = subprojects - project(':apps')
     
    74105    }
    75106
    76     jar {
    77         manifest {
    78             attributes 'Implementation-Version': "$fullVersion"
    79         }
    80     }
    81 
    82107    sourceCompatibility = 1.7
    83108    targetCompatibility = 1.7
     109
     110    jar {
     111        // Empty attributes are set by each project. They are initialized
     112        // here in order to create a defined ordering of the attributes.
     113        manifest {
     114            attributes 'Specification-Title': ''
     115            attributes 'Specification-Version': "$releaseVersion"
     116            attributes 'Specification-Vendor': 'The I2P Project https://geti2p.net/'
     117            attributes 'Implementation-Title': ''
     118            attributes 'Implementation-Version': "$fullVersion"
     119            attributes 'Implementation-Vendor': 'The I2P Project https://geti2p.net/'
     120            attributes 'Built-By': "$builtBy"
     121            attributes 'Build-Date': 'reproducible'
     122            attributes 'Base-Revision': "$workspaceVersion"
     123            attributes 'Workspace-Changes': ''
     124            attributes 'X-Compile-Source-JDK': "$sourceCompatibility"
     125            attributes 'X-Compile-Target-JDK': "$targetCompatibility"
     126        }
     127    }
    84128
    85129    tasks.withType(AbstractArchiveTask) {
Note: See TracChangeset for help on using the changeset viewer.