google-nomulus/gradle/core/build.gradle
jianglai c7fc964d9c Add a Gradle task to build the nomulus tool
It'd be nice if we can separate out the tool to its own package and reduce the transitive dependencies that it pulls in. However since the entire core project is a dependency of the tool, it doesn't make any difference as we'd be pulling in core and all its transitive dependencies as well.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224821931
2018-12-12 13:22:34 -05:00

467 lines
19 KiB
Groovy

plugins {
id 'java-library'
}
// Path to code generated by ad hoc tasks in this project. A separate path is
// used for easy inspection.
def generatedDir = "${project.buildDir}/generated/source/custom/main"
// Tests that conflict with (mostly unidentified) members of the main test
// suite. It is unclear if they are offenders (i.e., those that pollute global
// state) or victims.
// TODO(weiminyu): identify cause and fix offending tests.
def outcastTestPatterns = [
"google/registry/batch/DeleteContactsAndHostsActionTest.*",
"google/registry/batch/RefreshDnsOnHostRenameActionTest.*",
"google/registry/flows/CheckApiActionTest.*",
"google/registry/flows/EppLifecycleDomainTest.*",
"google/registry/flows/EppLifecycleHostTest.*",
"google/registry/flows/domain/DomainAllocateFlowTest.*",
"google/registry/flows/domain/DomainApplicationCreateFlowTest.*",
"google/registry/flows/domain/DomainApplicationUpdateFlowTest.*",
"google/registry/flows/domain/DomainCreateFlowTest.*",
"google/registry/flows/domain/DomainUpdateFlowTest.*",
"google/registry/tools/server/CreatePremiumListActionTest.*",
// Conflicts with WhoisActionTest
"google/registry/whois/WhoisHttpActionTest.*",
]
// Tests that conflict with members of both the main test suite and the
// outcast suite.
// TODO(weiminyu): identify cause and fix offending tests.
def fragileTestPatterns = [
"google/registry/cron/TldFanoutActionTest.*"
]
sourceSets {
main {
java {
srcDirs += generatedDir
}
resources {
exclude '**/*.xjb'
}
}
test {
resources {
exclude '**/*.xjb', '**/*.xsd'
}
}
}
configurations {
css
jaxb
soy
// Label for all dependencies inherited from Bazel build but not used in
// either compile or testRuntime. However, they may be needed at runtime.
// TODO(weiminyu): identify runtime dependencies and remove the rest.
maybeRuntime
}
// Known issues:
// - The (test/)compile/runtime labels are deprecated. We continue using these
// labels due to nebula-lint.
// TODO(weiminyu): switch to api/implementation labels.
// See https://github.com/nebula-plugins/gradle-lint-plugin/issues/130 for
// issue status.
// - Nebula-lint's conflict between unused and undeclared dependency check.
// If an undeclared dependency is added, the unused-dependency check will flag
// it. For now we wrap affected dependency in gradleLint.ignore block.
// TODO(weiminyu): drop gradleLint.ignore block when issue is fixed.
// See https://github.com/nebula-plugins/gradle-lint-plugin/issues/181 for
// issue status.
dependencies {
// Custom-built objectify jar at commit ecd5165, included in Nomulus
// release.
implementation files(
"${rootDir}/../third_party/objectify/v4_1/objectify-4.1.3.jar")
testImplementation project(':third_party')
compile 'com.beust:jcommander:1.48'
compile 'com.google.api-client:google-api-client:1.22.0'
maybeRuntime 'com.google.api-client:google-api-client-appengine:1.22.0'
maybeRuntime 'com.google.api-client:google-api-client-jackson2:1.20.0'
compile 'com.google.monitoring-client:metrics:1.0.4'
compile 'com.google.monitoring-client:stackdriver:1.0.4'
maybeRuntime 'com.google.api-client:google-api-client-java6:1.20.0'
maybeRuntime 'com.google.api-client:google-api-client-servlet:1.22.0'
compile 'com.google.apis:google-api-services-admin-directory:directory_v1-rev72-1.22.0'
compile 'com.google.apis:google-api-services-appengine:v1-rev85-1.25.0'
compile 'com.google.apis:google-api-services-bigquery:v2-rev325-1.22.0'
maybeRuntime 'com.google.apis:google-api-services-clouddebugger:v2-rev8-1.22.0'
compile 'com.google.apis:google-api-services-cloudkms:v1-rev12-1.22.0'
maybeRuntime 'com.google.apis:google-api-services-cloudresourcemanager:v1-rev6-1.22.0'
compile 'com.google.apis:google-api-services-dataflow:v1b3-rev196-1.22.0'
compile 'com.google.apis:google-api-services-dns:v2beta1-rev6-1.22.0'
compile 'com.google.apis:google-api-services-drive:v2-rev160-1.19.1'
compile 'com.google.apis:google-api-services-groupssettings:v1-rev60-1.22.0'
compile 'com.google.apis:google-api-services-monitoring:v3-rev11-1.22.0'
compile 'com.google.apis:google-api-services-sheets:v4-rev483-1.22.0'
maybeRuntime 'com.google.apis:google-api-services-storage:v1-rev86-1.22.0'
// TODO(b/71631624): change appengine:appengine-api-1.0-sdk to
// testCompileOnly after BillingEmailUtilsTest.java is fixed.
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.48'
maybeRuntime 'com.google.appengine:appengine-api-labs:1.9.48'
maybeRuntime 'com.google.appengine:appengine-api-stubs:1.9.48'
testCompile 'com.google.appengine:appengine-api-stubs:1.9.48'
compile 'com.google.appengine.tools:appengine-gcs-client:0.6'
compile 'com.google.appengine.tools:appengine-mapreduce:0.8.5'
compile 'com.google.appengine.tools:appengine-pipeline:0.2.13'
compile 'com.google.appengine:appengine-remote-api:1.9.48'
maybeRuntime 'com.google.appengine:appengine-tools-sdk:1.9.48'
compile 'com.google.auth:google-auth-library-credentials:0.7.1'
compile 'com.google.auth:google-auth-library-oauth2-http:0.7.1'
maybeRuntime 'com.google.auto:auto-common:0.8'
maybeRuntime 'com.google.auto.factory:auto-factory:1.0-beta3'
compile 'com.google.code.gson:gson:2.8.5'
compile 'com.google.auto.value:auto-value-annotations:1.6.2'
maybeRuntime 'com.google.cloud.bigdataoss:gcsio:1.4.5'
maybeRuntime 'com.google.cloud.bigdataoss:util:1.4.5'
compile 'com.google.code.findbugs:jsr305:3.0.2'
compile 'com.google.dagger:dagger:2.15'
maybeRuntime 'com.google.dagger:dagger-producers:2.15'
compile 'com.google.errorprone:error_prone_annotations:2.3.1'
maybeRuntime 'com.google.errorprone:javac-shaded:9-dev-r4023-3'
compile 'com.google.flogger:flogger:0.1'
runtime 'com.google.flogger:flogger-system-backend:0.1'
maybeRuntime 'com.google.gdata:core:1.47.1'
maybeRuntime 'com.google.googlejavaformat:google-java-format:1.4'
compile 'com.google.guava:guava:25.1-jre'
gradleLint.ignore('unused-dependency') {
compile 'com.google.gwt:gwt-user:2.8.2'
}
compile 'com.google.http-client:google-http-client:1.25.0'
compile 'com.google.http-client:google-http-client-appengine:1.22.0'
compile 'com.google.http-client:google-http-client-jackson2:1.25.0'
compile 'com.google.oauth-client:google-oauth-client:1.25.0'
maybeRuntime 'com.google.oauth-client:google-oauth-client-appengine:1.22.0'
compile 'com.google.oauth-client:google-oauth-client-java6:1.22.0'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.22.0'
maybeRuntime 'com.google.oauth-client:google-oauth-client-servlet:1.22.0'
maybeRuntime 'com.google.protobuf:protobuf-java:2.6.0'
compile 'com.google.re2j:re2j:1.1'
compile 'com.google.template:soy:2018-03-14'
maybeRuntime 'com.googlecode.charts4j:charts4j:1.3'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.jcraft:jsch:0.1.53'
maybeRuntime 'com.jcraft:jzlib:1.1.3'
maybeRuntime 'com.squareup:javapoet:1.8.0'
maybeRuntime 'com.squareup:javawriter:2.5.1'
maybeRuntime 'com.sun.activation:javax.activation:1.2.0'
maybeRuntime 'com.thoughtworks.paranamer:paranamer:2.7'
maybeRuntime 'commons-codec:commons-codec:1.10'
maybeRuntime 'commons-logging:commons-logging:1.2'
compile 'dnsjava:dnsjava:2.1.7'
maybeRuntime 'io.netty:netty-buffer:4.1.28.Final'
maybeRuntime 'io.netty:netty-codec:4.1.28.Final'
maybeRuntime 'io.netty:netty-codec-http:4.1.28.Final'
maybeRuntime 'io.netty:netty-common:4.1.28.Final'
maybeRuntime 'io.netty:netty-handler:4.1.28.Final'
maybeRuntime 'io.netty:netty-resolver:4.1.28.Final'
maybeRuntime 'io.netty:netty-tcnative:2.0.12.Final'
maybeRuntime 'io.netty:netty-tcnative-boringssl-static:2.0.12.Final'
maybeRuntime 'io.netty:netty-transport:4.1.28.Final'
maybeRuntime 'it.unimi.dsi:fastutil:6.5.16'
maybeRuntime 'javax.annotation:jsr250-api:1.0'
runtime 'org.glassfish.jaxb:jaxb-runtime:2.3.0'
testCompile 'javax.annotation:jsr250-api:1.0'
compile 'javax.inject:javax.inject:1'
compile 'javax.mail:mail:1.4'
compile 'javax.servlet:servlet-api:2.5'
compile 'javax.xml.bind:jaxb-api:2.3.0'
maybeRuntime 'javax.xml.soap:javax.xml.soap-api:1.4.0'
compile 'jline:jline:1.0'
compile 'joda-time:joda-time:2.3'
compile 'org.apache.avro:avro:1.8.2'
maybeRuntime 'org.apache.beam:beam-runners-direct-java:2.2.0'
testCompile 'org.apache.beam:beam-runners-direct-java:2.2.0'
compile 'org.apache.beam:beam-runners-google-cloud-dataflow-java:2.1.0'
maybeRuntime 'org.apache.beam:beam-sdks-common-runner-api:2.1.0'
compile 'org.apache.beam:beam-sdks-java-core:2.2.0'
compile 'org.apache.beam:beam-sdks-java-extensions-google-cloud-platform-core:2.1.0'
compile 'org.apache.beam:beam-sdks-java-io-google-cloud-platform:2.2.0'
maybeRuntime 'org.apache.commons:commons-compress:1.8.1'
maybeRuntime 'org.apache.ftpserver:ftplet-api:1.0.6'
testCompile 'org.apache.ftpserver:ftplet-api:1.0.6'
maybeRuntime 'org.apache.ftpserver:ftpserver-core:1.0.6'
testCompile 'org.apache.ftpserver:ftpserver-core:1.0.6'
compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
maybeRuntime 'org.apache.mina:mina-core:2.0.4'
maybeRuntime 'org.apache.sshd:sshd-core:2.0.0'
testCompile 'org.apache.sshd:sshd-core:2.0.0'
maybeRuntime 'org.apache.sshd:sshd-scp:2.0.0'
testCompile 'org.apache.sshd:sshd-scp:2.0.0'
maybeRuntime 'org.apache.sshd:sshd-sftp:2.0.0'
testCompile 'org.apache.sshd:sshd-sftp:2.0.0'
compile 'org.apache.tomcat:servlet-api:6.0.45'
maybeRuntime 'org.apache.tomcat:tomcat-annotations-api:8.0.5'
testCompile 'org.apache.tomcat:tomcat-annotations-api:8.0.5'
compile 'org.bouncycastle:bcpg-jdk15on:1.52'
testCompile 'org.bouncycastle:bcpkix-jdk15on:1.52'
compile 'org.bouncycastle:bcprov-jdk15on:1.52'
maybeRuntime 'org.codehaus.jackson:jackson-core-asl:1.9.13'
maybeRuntime 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
compile 'org.joda:joda-money:0.10.0'
compile 'org.json:json:20160810'
maybeRuntime 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
maybeRuntime 'org.mortbay.jetty:jetty:6.1.26'
testCompile 'org.mortbay.jetty:jetty:6.1.26'
compile 'org.mortbay.jetty:servlet-api:2.5-20081211'
maybeRuntime 'org.mortbay.jetty:jetty-util:6.1.26'
maybeRuntime 'org.slf4j:slf4j-api:1.7.16'
maybeRuntime 'org.tukaani:xz:1.5'
maybeRuntime 'org.xerial.snappy:snappy-java:1.1.4-M3'
compile 'xerces:xmlParserAPIs:2.6.2'
compile 'xpp3:xpp3:1.1.4c'
// Known issue: nebula-lint misses inherited dependency.
compile project(':third_party')
compile project(':util')
// Include auto-value in compile until nebula-lint understands
// annotationProcessor
gradleLint.ignore('unused-dependency') {
compile 'com.google.auto.value:auto-value:1.6.2'
}
annotationProcessor 'com.google.auto.value:auto-value:1.6.2'
testAnnotationProcessor 'com.google.auto.value:auto-value:1.6.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.15'
testAnnotationProcessor 'com.google.dagger:dagger-compiler:2.15'
testCompile 'com.google.appengine:appengine-testing:1.9.58'
testCompile 'com.google.guava:guava-testlib:25.0-jre'
testCompile 'com.google.monitoring-client:contrib:1.0.4'
testCompile 'com.google.truth:truth:0.42'
testCompile 'com.google.truth.extensions:truth-java8-extension:0.39'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.9.5'
// Indirect dependency found by undeclared-dependency check. Such
// dependencies should go after all other compile and testCompile
// dependencies to avoid overriding them accidentally.
compile 'javax.servlet:javax.servlet-api:3.1.0' // google-api-client-appeng
// Dependencies needed for jaxb compilation.
// Use jaxb 2.2.11 because 2.3 is known to break the Ant task we use.
// TODO: upgrade jaxb versions to 2.4.0, already in beta by Sept 2018
jaxb 'javax.xml.bind:jaxb-api:2.2.11'
jaxb 'com.sun.activation:javax.activation:1.2.0'
jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.11'
jaxb 'com.sun.xml.bind:jaxb-impl:2.2.11'
jaxb 'com.sun.xml.bind:jaxb-osgi:2.2.11'
// Dependency needed for soy to java compilation.
soy 'com.google.template:soy:2018-03-14'
// Dependencies needed for compiling stylesheets to javascript
css 'com.google.closure-stylesheets:closure-stylesheets:1.5.0'
css 'args4j:args4j:2.0.26'
}
task jaxbToJava {
doLast {
file(generatedDir).mkdirs()
// Temp dir to hold schema and bindings files. Files must be in the same
// directory because the bindings (.xjb) file does not declare relative
// paths to schema (.xsd) files.
def xjcTempSourceDir = file("${temporaryDir}/xjc")
xjcTempSourceDir.mkdirs()
ant.copy(
todir: "${xjcTempSourceDir}",
overwrite: true) {
fileSet(
dir: "${javaDir}/google/registry/xml/xsd",
includes: '**.xsd')
}
ant.copy(
todir: "${xjcTempSourceDir}",
overwrite: true,
file:
"${javaDir}/google/registry/xjc/bindings.xjb")
ant.taskdef(
name: 'xjc',
classname: 'com.sun.tools.xjc.XJCTask',
classpath: configurations.jaxb.asPath)
ant.xjc(
destdir: "${generatedDir}",
binding: "${xjcTempSourceDir}/bindings.xjb",
removeOldOutput: 'yes', extension: 'true') {
project.fileTree(
dir: new File("$xjcTempSourceDir"),
include: ['**/*.xsd'])
.addToAntBuilder(ant, 'schema', FileCollection.AntType.FileSet)
// -npa: do not generate package-info.java files. They will be generated
// below.
arg(line: '-npa -quiet -extension')
}
exec {
workingDir "${generatedDir}"
executable "${javaDir}/google/registry/xjc/make_pkginfo.sh"
args "${javaDir}/google/registry/xjc/package-info.java.in",
"${generatedDir}/google/registry/xjc"
}
}
}
task soyToJava {
ext.soyToJava = { javaPackage, outputDirectory, soyFiles ->
javaexec {
main = "com.google.template.soy.SoyParseInfoGenerator"
classpath configurations.soy
args "--javaPackage", "${javaPackage}",
"--outputDirectory", "${outputDirectory}",
"--javaClassNameSource", "filename",
"--allowExternalCalls", "true",
"--srcs", "${soyFiles.join(',')}"
}
}
doLast {
soyToJava('google.registry.tools.soy',
"${generatedDir}/google/registry/tools/soy",
fileTree(
dir: "${javaDir}/google/registry/tools/soy",
include: ['**/*.soy']))
soyToJava('google.registry.ui.soy.registrar',
"${generatedDir}/google/registry/ui/soy/registrar",
fileTree(
dir: "${javaDir}/google/registry/ui/soy/registrar",
include: ['**/*.soy']))
soyToJava('google.registry.ui.soy',
"${generatedDir}/google/registry/ui/soy",
files {
file("${javaDir}/google/registry/ui/soy").listFiles()
}.filter {
it.name.endsWith(".soy")
})
}
}
task stylesheetsToJavascript {
ext.cssCompile = { outputName, debug, cssFiles ->
javaexec {
main = "com.google.common.css.compiler.commandline.ClosureCommandLineCompiler"
classpath configurations.css
def argsBuffer = [
"--output-file", "${outputName}.css",
"--output-source-map", "${outputName}.css.map",
"--input-orientation", "LTR",
"--output-orientation", "NOCHANGE",
"--output-renaming-map", "${outputName}.css.js",
"--output-renaming-map-format", "CLOSURE_COMPILED_SPLIT_HYPHENS"
]
if (debug) {
argsBuffer.addAll(["--rename", "DEBUG", "--pretty-print"])
} else {
argsBuffer.addAll(["--rename", "CLOSURE"])
}
argsBuffer.addAll(cssFiles)
args argsBuffer
}
}
doLast {
def cssSourceDir = "${javaDir}/google/registry/ui/css"
def outputDir = "${project.buildDir}/resources/main/google/registry/ui/css"
file("${outputDir}").mkdirs()
def srcFiles = [
"${cssSourceDir}/console.css",
"${cssSourceDir}/contact-settings.css",
"${cssSourceDir}/contact-us.css",
"${cssSourceDir}/dashboard.css",
"${cssSourceDir}/epp.css",
"${cssSourceDir}/forms.css",
"${cssSourceDir}/kd_components.css",
"${cssSourceDir}/registry.css",
"${cssSourceDir}/resources.css",
"${cssSourceDir}/security-settings.css"
]
cssCompile("${outputDir}/registrar_bin", false, srcFiles)
cssCompile("${outputDir}/registrar_dbg", true, srcFiles)
}
}
compileJava.dependsOn jaxbToJava
compileJava.dependsOn soyToJava
// stylesheetsToJavascript must happen after processResources, which wipes the
// resources folder before copying data into it.
stylesheetsToJavascript.dependsOn processResources
classes.dependsOn stylesheetsToJavascript
// Make testing artifacts available to be depended up on by other projects.
// TODO: factor out google.registry.testing to be a separate project.
task testJar(type: Jar) {
classifier = 'test'
from sourceSets.test.output
}
artifacts {
testRuntime testJar
}
task fragileTest(type: Test) {
// Common exclude pattern. See README in parent directory for explanation.
exclude "**/*TestCase.*", "**/*TestSuite.*"
include fragileTestPatterns
// Run every test class in a freshly started process.
forkEvery 1
// Uncomment to see test outputs in stdout.
//testLogging.showStandardStreams = true
}
task outcastTest(type: Test) {
// Common exclude pattern. See README in parent directory for explanation.
exclude "**/*TestCase.*", "**/*TestSuite.*"
include outcastTestPatterns
// Sets the maximum number of test executors that may exist at the same time.
maxParallelForks 5
}
test {
// Common exclude pattern. See README in parent directory for explanation.
exclude "**/*TestCase.*", "**/*TestSuite.*"
exclude fragileTestPatterns
exclude outcastTestPatterns
// Sets the maximum number of test executors that may exist at the same time.
maxParallelForks 5
}.dependsOn(fragileTest, outcastTest)
task nomulus(type: Jar) {
manifest {
attributes 'Main-Class': 'google.registry.tools.RegistryTool'
}
zip64 = true
baseName = 'nomulus'
version = null
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
// Excludes signature files that accompany some dependency jars, like
// bonuncycastle. It they are present, only classes from those signed jars are
// made available to the class loader.
// see https://discuss.gradle.org/t/signing-a-custom-gradle-plugin-thats-downloaded-by-the-build-system-from-github/1365
exclude "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA"
with jar
dependsOn project(':third_party').jar
}