Github user jeking3 commented on a diff in the pull request: https://github.com/apache/thrift/pull/1468#discussion_r161387659 --- Diff: lib/java/build.gradle --- @@ -0,0 +1,495 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +apply plugin: 'java' +apply plugin: 'maven' +apply plugin: 'signing' + +description = 'Apache Thrift Java Library' + +defaultTasks 'build' + +// Override the build directory id CMake is used +if (hasProperty('build.dir')) { + buildDir = file(property('build.dir')) +} + +// In order to remain compatible with other Ant based builds in the system +// we convert the gradle.properties into DSL friendly camelCased properties +ext.thriftVersion = property('thrift.version') +ext.installPath = property('install.path') +ext.installJavadocPath = property('install.javadoc.path') + +ext.thriftRoot = file('../..') + +if (hasProperty('thrift.compiler')) { + ext.thriftCompiler = property('thrift.compiler') +} else { + ext.thriftCompiler = "$thriftRoot/compiler/cpp/thrift" +} + +ext.mvnRepo = property('mvn.repo') +ext.apacheRepo = property('apache.repo') +ext.mavenRepositoryUrl = property('maven-repository-url') + +// Versions used in this project +ext.httpclientVersion = property('httpclient.version') +ext.httpcoreVersion = property('httpcore.version') +ext.servletVersion = property('servlet.version') +ext.slf4jVersion = property('slf4j.version') +ext.junitVersion = property('junit.version') +ext.mockitoVersion = property('mockito.version') + +// Version components for this project +group = property('thrift.groupid') + +if (Boolean.parseBoolean(project.release)) { + version = "$thriftVersion" +} else { + version = "$thriftVersion-SNAPSHOT" +} + +// In this section you declare where to find the dependencies of your project +repositories { + maven { + name 'Maven Central Repository' + url mvnRepo + } + maven { + name 'Apache Maven Repository' + url apacheRepo + } +} + +dependencies { + compile "org.slf4j:slf4j-api:${slf4jVersion}" + compile "org.apache.httpcomponents:httpclient:${httpclientVersion}" + compile "org.apache.httpcomponents:httpcore:${httpcoreVersion}" + compile "javax.servlet:servlet-api:${servletVersion}" + + testCompile "junit:junit:${junitVersion}" + testCompile "org.mockito:mockito-all:${mockitoVersion}" + testRuntime "org.slf4j:slf4j-log4j12:${slf4jVersion}" +} + +// Generated code for Unit tests +ext.genSrc = file("$buildDir/gen-java") +ext.genBeanSrc = file("$buildDir/gen-javabean") +ext.genReuseSrc = file("$buildDir/gen-javareuse") +ext.genFullCamelSrc = file("$buildDir/gen-fullcamel") + +sourceSets { + main { + java { + srcDir 'src' + } + } + + test { + java { + srcDir 'test' + srcDir genSrc + srcDir genBeanSrc + srcDir genReuseSrc + srcDir genFullCamelSrc + } + resources { + srcDir 'test' + include 'log4j.properties' + } + } +} + +// ---------------------------------------------------------------------------- +// Code generation for Unit Testing +ext.testThriftHome = file("$thriftRoot/test") + +// A callable closure to make this easier +ext.thriftCompile = { Task task, String thriftFileName, String generator = 'java', File outputDir = genSrc -> + def thriftFile = file("$testThriftHome/$thriftFileName") + assert thriftFile.exists() + + task.inputs.file thriftFile + task.outputs.dir outputDir + + task.doLast { + outputDir.mkdirs() + exec { + executable file(thriftCompiler) + args '--gen', generator + args '-out', outputDir + args thriftFile + } + } +} + +task generate(group: 'Build') { + description = 'Generate all unit test Thrift sources' +} + +task generateJava(group: 'Build') { + description = 'Generate the thrift gen-java source' + + generate.dependsOn it + compileTestJava.dependsOn it + + thriftCompile(it, 'ThriftTest.thrift') + thriftCompile(it, 'JavaTypes.thrift') + thriftCompile(it, 'DebugProtoTest.thrift') + thriftCompile(it, 'OptionalRequiredTest.thrift') + thriftCompile(it, 'ManyOptionals.thrift') + thriftCompile(it, 'JavaDeepCopyTest.thrift') + thriftCompile(it, 'EnumContainersTest.thrift') +} + +task generateBeanJava(group: 'Build') { + description = 'Generate the thrift gen-javabean source' + + generate.dependsOn it + compileTestJava.dependsOn it + + thriftCompile(it, 'JavaBeansTest.thrift', 'java:beans,nocamel', genBeanSrc) +} + +task generateReuseJava(group: 'Build') { + description = 'Generate the thrift gen-javareuse source' + + generate.dependsOn it + compileTestJava.dependsOn it + + thriftCompile(it, 'FullCamelTest.thrift', 'java:fullcamel', genFullCamelSrc) +} + +task generateFullCamelJava(group: 'Build') { + description = 'Generate the thrift gen-fullcamel source' + + generate.dependsOn it + compileTestJava.dependsOn it + + thriftCompile(it, 'ReuseObjects.thrift', 'java:reuse-objects', genReuseSrc) +} + +// ---------------------------------------------------------------------------- +// Compiler configuration details + +sourceCompatibility = '1.6' +targetCompatibility = '1.6' + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' + options.debug = true + options.deprecation = true + // options.compilerArgs.addAll('-Xlint:unchecked') +} + +// ---------------------------------------------------------------------------- +// Jar packaging details +processResources { + into('META-INF') { + from "$thriftRoot/LICENSE" + from "$thriftRoot/NOTICE" + rename('(.+)', '$1..txt') + } +} + +jar { + manifest { + attributes([ + "Implementation-Version": "${project.version}", + "Bundle-ManifestVersion": "2", + "Bundle-SymbolicName": "${project.group}", + "Bundle-Name": "Apache Thrift", + "Bundle-Version": "${project.version}", + "Bundle-Description": "Apache Thrift library", + "Bundle-License": "${project.license}", + "Bundle-ActivationPolicy": "lazy", + "Export-Package": "${project.group}.async;uses:=\"${project.group}.protocol,${project.group}.transport,org.slf4j,${project.group}\";version=\"${version}\",${project.group}.protocol;uses:=\"${project.group}.transport,${project.group},${project.group}.scheme\";version=\"${version}\",${project.group}.server;uses:=\"${project.group}.transport,${project.group}.protocol,${project.group},org.slf4j,javax.servlet,javax.servlet.http\";version=\"${version}\",${project.group}.transport;uses:=\"${project.group}.protocol,${project.group},org.apache.http.client,org.apache.http.params,org.apache.http.entity,org.apache.http.client.methods,org.apache.http,org.slf4j,javax.net.ssl,javax.net,javax.security.sasl,javax.security.auth.callback\";version=\"${version}\",${project.group};uses:=\"${project.group}.protocol,${project.group}.async,${project.group}.server,${project.group}.transport,org.slf4j,org.apache.log4j,${project.group}.scheme\";version=\"${version}\",${project.group}.meta_data ;uses:=\"${project.group}\";version=\"${version}\",${project.group}.scheme;uses:=\"${project.group}.protocol,${project.group}\";version=\"${version}\"", + "Import-Package": "javax.net,javax.net.ssl,javax.security.auth.callback,javax.security.sasl,javax.servlet;resolution:=optional,javax.servlet.http;resolution:=optional,org.slf4j;resolution:=optional;version=\"[1.4,2)\",org.apache.http.client;resolution:=optional,org.apache.http.params;resolution:=optional,org.apache.http.entity;resolution:=optional,org.apache.http.client.methods;resolution:=optional,org.apache.http;resolution:=optional" + ]) + } +} + +task sourcesJar(type: Jar, group: 'Build') { + description = 'Assembles a jar archive containing the main Java sources.' + + classifier 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc, group: 'Build') { + description = 'Assembles a jar archive containing the JavaDoc.' + + classifier 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + + +task copyDependencies(type: Copy, group: 'Build') { + description = 'Copy Test runtime dependencies in a common location for other Ant based projects' + assemble.dependsOn it + + destinationDir = file("$buildDir/deps") + from configurations.testRuntime +} + +// ---------------------------------------------------------------------------- +// Installation subtasks, hooked on Maven install task +task installDist(type: Copy, group: 'Install') { + description = "Copy Thrift JAR and dependencies into $installPath location" + install.dependsOn it + + destinationDir = file(installPath) + + from jar + from configurations.compile +} + +task installJavadoc(type: Copy, group: 'Install', dependsOn: javadoc) { + description = "Install Thrift JavaDoc into $installJavadocPath location" + install.dependsOn it + + destinationDir = file(installJavadocPath) + + from javadoc.destinationDir +} + +// ---------------------------------------------------------------------------- +// Unit test tasks and configurations +task deprecatedEqualityTest(type: JavaExec, group: 'Validation') { + description = 'Run the non-JUnit test suite ' + classpath = sourceSets.test.runtimeClasspath + main 'org.apache.thrift.test.EqualityTest' +} + +task deprecatedJavaBeansTest(type: JavaExec, group: 'Validation') { + description = 'Run the non-JUnit test suite ' + classpath = sourceSets.test.runtimeClasspath + main 'org.apache.thrift.test.JavaBeansTest' +} + +task testclient(type: JavaExec, group: 'Validation') { + description="Run a test client" + classpath = sourceSets.test.runtimeClasspath + main 'org.apache.thrift.test.TestClient' + + systemProperties = [ + 'javax.net.ssl.trustStore': "${projectDir}/test/.truststore", + 'javax.net.ssl.trustStorePassword': 'thrift' + ] + + if (project.hasProperty('testargs')) { + args "$testargs".split(' ') + } +} + +task testserver(type: JavaExec, group: 'Validation') { + description="Run a test server" + classpath = sourceSets.test.runtimeClasspath + main 'org.apache.thrift.test.TestServer' + + systemProperties = [ + 'javax.net.ssl.keyStore': "${projectDir}/test/.keystore", + 'javax.net.ssl.keyStorePassword': 'thrift' + ] + + if (project.hasProperty('testargs')) { + args "$testargs".split(' ') + } +} + +task testnonblockingserver(type: JavaExec, group: 'Validation') { + description="Run a test nonblocking server" + classpath = sourceSets.test.runtimeClasspath + main 'org.apache.thrift.test.TestNonblockingServer' + + systemProperties = [ + 'javax.net.ssl.keyStore': "${projectDir}/test/.keystore", + 'javax.net.ssl.keyStorePassword': 'thrift' + ] + + if (project.hasProperty('testargs')) { + args "$testargs".split(' ') + } +} + +// Main Unit Test task configuration +test { + description="Run the full test suite" + dependsOn deprecatedEqualityTest, deprecatedJavaBeansTest + + // Allow repeating tests even after successful execution + if (project.hasProperty('rerunTests')) { + outputs.upToDateWhen { false } + } + + include '**/Test*.class' + exclude '**/Test*\$*.class' + exclude '**/TestClient.class' + exclude '**/TestServer.class' + exclude '**/TestNonblockingServer.class' + + maxHeapSize = '512m' + forkEvery = 1 + + systemProperties = [ + 'build.test': "${compileTestJava.destinationDir}", + 'test.port': "${testPort}", + 'javax.net.ssl.trustStore': "${projectDir}/test/.truststore", + 'javax.net.ssl.trustStorePassword': 'thrift', + 'javax.net.ssl.keyStore': "${projectDir}/test/.keystore", + 'javax.net.ssl.keyStorePassword': 'thrift' + ] +} + +// ---------------------------------------------------------------------------- +// Allow this configuration to be shared between install and uploadArchives tasks +def configurePom(pom) { + pom.project { + name 'Apache Thrift' + description 'Thrift is a software framework for scalable cross-language services development.' + packaging 'jar' + url 'http://thrift.apache.org' + + scm { + url 'https://git-wip-us.apache.org/repos/asf?p=thrift.git' + connection 'scm:git:https://git-wip-us.apache.org/repos/asf/thrift.git' + developerConnection 'scm:git:https://git-wip-us.apache.org/repos/asf/thrift.git' + } + + licenses { + license { + name 'The Apache Software License, Version 2.0' + url "${project.license}" + distribution 'repo' + } + } + + developers { --- End diff -- This list can be condensed down to: ``` developer { id 'dev' name 'Apache Thrift Developers' email 'dev@thrift.apache.org' } ``` I believe this information is used elsewhere, for example in CPAN packaging.
---