forked from I2P_Developers/i2p.i2p

JDK 9+ have a --release flag that correctly configures the bootClasspath. For JDK 8 we now enforce manual configuration.
125 lines
3.6 KiB
Groovy
125 lines
3.6 KiB
Groovy
plugins {
|
|
id 'idea'
|
|
}
|
|
|
|
String getReleaseVersion() {
|
|
def releaseVersion
|
|
file("core/java/src/net/i2p/CoreVersion.java").readLines().findAll({ line ->
|
|
line.contains("public final static String VERSION")
|
|
}).first().eachMatch('.*"([^"]+)";', {
|
|
releaseVersion = it[1]
|
|
})
|
|
releaseVersion
|
|
}
|
|
|
|
String getBuildVersion() {
|
|
def buildVersion
|
|
file("router/java/src/net/i2p/router/RouterVersion.java").readLines().findAll({ line ->
|
|
line.contains("public final static long BUILD")
|
|
}).first().eachMatch('.*=\\s+([0-9]+);', {
|
|
buildVersion = it[1]
|
|
})
|
|
buildVersion
|
|
}
|
|
|
|
String getBuildExtra() {
|
|
def buildExtra
|
|
file("router/java/src/net/i2p/router/RouterVersion.java").readLines().findAll({ line ->
|
|
line.contains("public final static String EXTRA")
|
|
}).first().eachMatch('.*"(.*)";', {
|
|
buildExtra = it[1]
|
|
})
|
|
buildExtra
|
|
}
|
|
|
|
String compat(String src) {
|
|
if (src.contains('.')) {
|
|
src.substring(src.lastIndexOf('.') + 1)
|
|
} else {
|
|
src
|
|
}
|
|
}
|
|
|
|
def releaseVersion = getReleaseVersion()
|
|
def buildVersion = getBuildVersion()
|
|
def buildExtra = getBuildExtra()
|
|
def fullVersion = "$releaseVersion-$buildVersion$buildExtra"
|
|
|
|
// Exclude apps/ dir itself, but include its subdirs
|
|
def javaProjects = subprojects - project(':apps')
|
|
|
|
configure(javaProjects) {
|
|
apply plugin: 'java'
|
|
apply plugin: 'jacoco'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'idea'
|
|
|
|
repositories {
|
|
jcenter()
|
|
}
|
|
|
|
dependencies {
|
|
testCompile 'junit:junit:4.+'
|
|
testCompile 'org.hamcrest:hamcrest-library:1.3'
|
|
testCompile 'org.mockito:mockito-core:2.11.0'
|
|
}
|
|
|
|
jar {
|
|
manifest {
|
|
attributes 'Implementation-Version': "$fullVersion"
|
|
}
|
|
}
|
|
|
|
sourceCompatibility = 1.7
|
|
targetCompatibility = 1.7
|
|
|
|
def i2pBootClasspath
|
|
// Set java7BootClasspath=/path/to/rt.jar:/path/to/jce.jar in ~/.gradle/gradle.properties if needed
|
|
if (java7BootClasspath) {
|
|
i2pBootClasspath = java7BootClasspath
|
|
} else {
|
|
def java7Home = System.getenv("JAVA7_HOME")
|
|
if (java7Home) {
|
|
i2pBootClasspath = "${java7Home}/jre/lib/jce.jar:${java7Home}/jre/lib/rt.jar"
|
|
}
|
|
}
|
|
|
|
if (i2pBootClasspath) {
|
|
tasks.withType(AbstractCompile, { AbstractCompile ac ->
|
|
ac.options.bootstrapClasspath = files(i2pBootClasspath)
|
|
})
|
|
} else {
|
|
if (JavaVersion.current().java8Compatible && !JavaVersion.current().java9Compatible) {
|
|
throw new GradleException("Set java7BootClasspath property or JAVA7_HOME environment variable to enable cross-compilation, or run Gradle with JDK 9+")
|
|
}
|
|
tasks.withType(JavaCompile) {
|
|
def version = compat(sourceCompatibility)
|
|
logger.info("Configuring $name to use --release $version")
|
|
options.compilerArgs.addAll(['--release', version])
|
|
}
|
|
}
|
|
}
|
|
|
|
task codeCoverageReport(type: JacocoReport) {
|
|
dependsOn(javaProjects.test)
|
|
|
|
jacocoClasspath = project(':core').configurations.jacocoAnt
|
|
additionalSourceDirs = files(javaProjects.sourceSets.main.allSource.srcDirs)
|
|
sourceDirectories = files(javaProjects.sourceSets.main.allSource.srcDirs)
|
|
classDirectories = files(javaProjects.sourceSets.main.output)
|
|
executionData = files(javaProjects.jacocoTestReport.executionData)
|
|
|
|
doFirst {
|
|
executionData = files(executionData.findAll { it.exists() })
|
|
}
|
|
|
|
reports {
|
|
xml.enabled true
|
|
xml.destination file("${buildDir}/reports/jacoco/report.xml")
|
|
html.enabled true
|
|
html.destination file("${buildDir}/reports/jacoco/html")
|
|
}
|
|
}
|
|
|
|
//apply from: file('gradle/update.gradle')
|