source: build.gradle @ a1b67e3

Last change on this file since a1b67e3 was a1b67e3, checked in by str4d <str4d@…>, 14 months ago

Gradle: Parse router version from Java source

  • Property mode set to 100644
File size: 2.7 KB
Line 
1plugins {
2    id 'idea'
3}
4
5String getReleaseVersion() {
6    def releaseVersion
7    file("core/java/src/net/i2p/CoreVersion.java").readLines().findAll({ line ->
8        line.contains("public final static String VERSION")
9    }).first().eachMatch('.*"([^"]+)";', {
10        releaseVersion = it[1]
11    })
12    releaseVersion
13}
14
15String getBuildVersion() {
16    def buildVersion
17    file("router/java/src/net/i2p/router/RouterVersion.java").readLines().findAll({ line ->
18        line.contains("public final static long BUILD")
19    }).first().eachMatch('.*=\\s+([0-9]+);', {
20        buildVersion = it[1]
21    })
22    buildVersion
23}
24
25String getBuildExtra() {
26    def buildExtra
27    file("router/java/src/net/i2p/router/RouterVersion.java").readLines().findAll({ line ->
28        line.contains("public final static String EXTRA")
29    }).first().eachMatch('.*"(.*)";', {
30        buildExtra = it[1]
31    })
32    buildExtra
33}
34
35def releaseVersion = getReleaseVersion()
36def buildVersion = getBuildVersion()
37def buildExtra = getBuildExtra()
38def fullVersion = "$releaseVersion-$buildVersion$buildExtra"
39
40// Exclude apps/ dir itself, but include its subdirs
41def javaProjects = subprojects - project(':apps')
42
43configure(javaProjects) {
44    apply plugin: 'java'
45    apply plugin: 'jacoco'
46    apply plugin: 'eclipse'
47    apply plugin: 'idea'
48
49    repositories {
50        jcenter()
51    }
52
53    dependencies {
54        testCompile 'junit:junit:4.+'
55        testCompile 'org.hamcrest:hamcrest-library:1.3'
56        testCompile 'org.mockito:mockito-core:2.11.0'
57    }
58
59    jar {
60        manifest {
61            attributes 'Implementation-Version': "$fullVersion"
62        }
63    }
64
65    sourceCompatibility = 1.7
66    // Set i2pBootClasspath=/path/to/rt.jar:/path/to/jce.jar in ~/.gradle/gradle.properties if needed
67    if (i2pBootClasspath) {
68        tasks.withType(AbstractCompile, { AbstractCompile ac ->
69            ac.options.bootstrapClasspath = files(i2pBootClasspath)
70        })
71    }
72}
73
74task codeCoverageReport(type: JacocoReport) {
75    dependsOn(javaProjects.test)
76
77    jacocoClasspath = project(':core').configurations.jacocoAnt
78    additionalSourceDirs = files(javaProjects.sourceSets.main.allSource.srcDirs)
79    sourceDirectories = files(javaProjects.sourceSets.main.allSource.srcDirs)
80    classDirectories = files(javaProjects.sourceSets.main.output)
81    executionData = files(javaProjects.jacocoTestReport.executionData)
82
83    doFirst {
84        executionData = files(executionData.findAll { it.exists() })
85    }
86
87    reports {
88        xml.enabled true
89        xml.destination file("${buildDir}/reports/jacoco/report.xml")
90        html.enabled true
91        html.destination file("${buildDir}/reports/jacoco/html")
92    }
93}
94
95//apply from: file('gradle/update.gradle')
Note: See TracBrowser for help on using the repository browser.