Skip to content

Commit

Permalink
reproducible builds with Gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatinb committed May 11, 2021
1 parent 121cb2c commit 8532103
Show file tree
Hide file tree
Showing 14 changed files with 402 additions and 24 deletions.
14 changes: 12 additions & 2 deletions apps/addressbook/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin:'war'

sourceSets {
main {
java {
Expand All @@ -7,6 +9,14 @@ sourceSets {
}

dependencies {
compile project(':core')
compile project(':apps:jetty')
providedCompile project(':core')
providedCompile project(':apps:jetty')
}

war {
rootSpec.exclude('**/*.class')
}

artifacts {
archives war
}
4 changes: 4 additions & 0 deletions apps/i2pcontrol/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ war {
archiveName 'jsonrpc.war'
webXml = file('web.xml')
}

artifacts {
archives war
}
2 changes: 1 addition & 1 deletion apps/i2psnark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ task i2psnarkJar(type: Jar) {
// TODO: standalone jar. This is rather involved!

artifacts {
archives i2psnarkJar
archives i2psnarkJar,war
}

// Create the java files from the po files. The jar task will compile them.
Expand Down
87 changes: 81 additions & 6 deletions apps/i2ptunnel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ dependencies {
providedCompile project(':apps:ministreaming')
compile 'gnu.getopt:java-getopt:1.0.13'
providedCompile project(':apps:jetty')

implementation 'org.apache.ant:ant:1.10.10'
implementation fileTree("../jetty/apache-tomacat-${tomcatVersion}")
}

// Create the java files from the po files. The jar task will compile them.
Expand Down Expand Up @@ -62,8 +65,73 @@ task i2ptunnelJar(type: Jar) {
into "net/i2p/i2ptunnel/resources"
})
}

task helpersJar(type: Jar) {
from sourceSets.main.output
include '**/EditBean.class'
include '**/IndexBean.class'
include 'net/i2p/i2ptunnel/ui/**'
include 'net/i2p/i2ptunnel/web/SSLHelper.class'
archiveBaseName='i2pTunnelHelpers'
}

task precompileJsp(type : JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'net.i2p.servlet.util.JspC'

jvmArgs "-Dtomcat.util.scan.StandardJarScanFilter.jarsToSkip=commons-collections.jar,junit.jar,junit4.jar"
jvmArgs "-Dbuild.reproducible=true"

args "-d"
args "jsp/WEB-INF/classes"
args "-v"
args "-p"
args "net.i2p.i2ptunnel.jsp"
args "-webinc"
args "$buildDir/web-fragment.xml"
args "-webapp"
args "jsp"
doLast {
def output = new File("$buildDir/compiledJsps")
output.mkdirs()
ant.javac(srcDir: "jsp/WEB-INF/classes",
classpath: sourceSets.main.runtimeClasspath.asPath,
debug : true,
includeAntRuntime : false,
deprecation : "on",
source: project.sourceCompatibility,
target: project.targetCompatibility,
destDir:file("$buildDir/compiledJsps"))

def fragment = file("$buildDir/web-fragment.xml").text
def templateXML = file("jsp/web.xml").text
def webXML = templateXML.replace("<!-- precompiled servlets -->", fragment)

def multipart = "<multipart-config>" +
"<max-file-size>134217728</max-file-size>" +
"<max-request-size>134217728</max-request-size>" +
"<file-size-threshold>262144</file-size-threshold>" +
"</multipart-config>"

def multipartServlets = ["register"]


multipartServlets = multipartServlets.collect {
"<servlet-class>net.i2p.i2ptunnel.jsp.${it}_jsp</servlet-class>"
}

multipartServlets.each {
webXML = webXML.replace(it, it + multipart)
}

file("$buildDir/web.xml").text = webXML
}


}

i2ptunnelJar.dependsOn bundleProxy
war.dependsOn bundle
war.dependsOn bundle,precompileJsp

// not needed unless we're building for both android and regular
task tempBeansJar(type: Jar) {
Expand All @@ -85,14 +153,19 @@ task uiJar(type: Jar) {
}

artifacts {
archives i2ptunnelJar //, tempBeansJar, uiJar
archives i2ptunnelJar,war //, tempBeansJar, uiJar
}

war {
include '**/EditBean.class'
include '**/ui/*.class'
include '**/IndexBean.class'
from 'jsp'
from ("$buildDir/compiledJsps") {
include '**/*.class'
into "WEB-INF/classes"
}
rootSpec.exclude('**/*.jar')
rootSpec.exclude('/net/i2p/i2ptunnel/*.class')
rootSpec.exclude('/net/i2p/i2ptunnel/access')
rootSpec.exclude('/net/i2p/i2ptunnel/irc')
Expand All @@ -102,9 +175,11 @@ war {
rootSpec.exclude('/net/i2p/i2ptunnel/streamr')
rootSpec.exclude('/net/i2p/i2ptunnel/udp')
rootSpec.exclude('/net/i2p/i2ptunnel/udpTunnel')
exclude 'jsp/web.xml'
exclude '*.jsi'
exclude '*.jsp'
webXml = file('jsp/web.xml')
from("jsp") {
exclude 'web.xml'
exclude '*.jsi'
exclude '*.jsp'
}
webXml = file("$buildDir/web.xml")
}

6 changes: 5 additions & 1 deletion apps/imagegen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sourceSets {
}

dependencies {
compile project(':core')
providedCompile project(':core')
providedCompile project(':apps:jetty')
}

Expand All @@ -23,3 +23,7 @@ war {
from 'imagegen/webapp/src/main/webapp/index.html'
webXml = file('imagegen/webapp/src/main/webapp/WEB-INF/web.xml')
}

artifacts {
archives war
}
2 changes: 1 addition & 1 deletion apps/jetty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sourceSets {

dependencies {
ext.jettyVersion = '9.3.29.v20201019'
ext.tomcatVersion = '9.0.40'
ext.tomcatVersion = "${tomcatVersion}"
compile project(':core')
compile 'org.eclipse.jetty:jetty-http:' + ext.jettyVersion
compile 'org.eclipse.jetty:jetty-io:' + ext.jettyVersion
Expand Down
92 changes: 83 additions & 9 deletions apps/routerconsole/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ dependencies {
compile project(':core')
compile project(':router')
compile project(':installer')

// below were providedCompile
providedCompile project(':apps:desktopgui')
providedCompile project(':apps:systray')
providedCompile project(':apps:jetty')
providedCompile project(':apps:jrobin')

implementation 'org.apache.ant:ant:1.10.10'
implementation fileTree("../jetty/apache-tomacat-${tomcatVersion}")
testCompile "org.scala-lang:scala-library:2.12.4"
testCompile 'org.scalatest:scalatest_2.12:3.0.4'
}
Expand Down Expand Up @@ -77,26 +81,96 @@ task consoleJar(type: Jar) {
into "net/i2p/router/news/resources"
})
}
consoleJar.dependsOn bundleJar
war.dependsOn bundle

artifacts {
archives consoleJar
task helpersJar(type: Jar) {
from sourceSets.main.output
include 'net/i2p/router/web/helpers/**'
archiveBaseName = 'consoleHelpers'
}


task precompileJsp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'net.i2p.servlet.util.JspC'

jvmArgs "-Dtomcat.util.scan.StandardJarScanFilter.jarsToSkip=commons-collections.jar,junit.jar,junit4.jar"
jvmArgs "-Dbuild.reproducible=true"

args "-d"
args "jsp/WEB-INF/classes"
args "-v"
args "-p"
args "net.i2p.router.web.jsp"
args "-webinc"
args "$buildDir/web-fragment.xml"
args "-webapp"
args "jsp"
doLast {
def output = new File("$buildDir/compiledJsps")
output.mkdirs()
ant.javac(srcDir: "jsp/WEB-INF/classes",
classpath: sourceSets.main.runtimeClasspath.asPath,
debug : true,
includeAntRuntime : false,
deprecation : "on",
source: project.sourceCompatibility,
target: project.targetCompatibility,
destDir:file("$buildDir/compiledJsps"))

def fragment = file("$buildDir/web-fragment.xml").text
def templateXML = file("jsp/web.xml").text
def webXML = templateXML.replace("<!-- precompiled servlets -->", fragment)

def multipart = "<multipart-config>" +
"<max-file-size>134217728</max-file-size>" +
"<max-request-size>134217728</max-request-size>" +
"<file-size-threshold>262144</file-size-threshold>" +
"</multipart-config>"

def multipartServlets = ["configplugins",
"configfamily",
"configreseed"]

multipartServlets = multipartServlets.collect {
"<servlet-class>net.i2p.router.web.jsp.${it}_jsp</servlet-class>"
}

multipartServlets.each {
webXML = webXML.replace(it, it + multipart)
}

file("$buildDir/web.xml").text = webXML
}

}

consoleJar.dependsOn bundleJar
war.dependsOn(bundle,precompileJsp)


war {
rootSpec.exclude('**/*.jar')
rootSpec.exclude('/com/vuze/**/*')
rootSpec.exclude('/edu/internet2/**/*')
rootSpec.exclude('/net/i2p/router/news/*')
rootSpec.exclude('/net/i2p/router/sybil/*')
rootSpec.exclude('/net/i2p/router/update/*')
rootSpec.exclude('/net/i2p/router/web/*.class')
from 'jsp'
exclude 'jsp/web.xml'
exclude '*.jsi'
exclude '*.jsp'
webXml = file('jsp/web.xml')
from ("$buildDir/compiledJsps") {
into "WEB-INF/classes"
}
from ('jsp') {
exclude 'web.xml'
exclude '*.jsi'
exclude '*.jsp'
}
webXml = file("$buildDir/web.xml")
from ('resources', {
into "WEB-INF/classes/net/i2p/router/web/resources"
})
}

artifacts {
archives war,consoleJar
}

Loading

0 comments on commit 8532103

Please sign in to comment.