build: move build logic from build scripts to plugins in buildSrc
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/56793996 Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/56793996 Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/56793996 Branch: refs/heads/develop Commit: 56793996813773b8f421a29bd38534a1e1a02769 Parents: abf9280 Author: Paul Merlin <[email protected]> Authored: Fri Nov 11 20:22:21 2016 +0100 Committer: Paul Merlin <[email protected]> Committed: Sat Nov 19 01:43:29 2016 +0100 ---------------------------------------------------------------------- build.gradle | 1005 +----------------- buildSrc/build.gradle | 11 + .../apache/zest/gradle/AllProjectsPlugin.groovy | 178 ++++ .../zest/gradle/CodeProjectsPlugin.groovy | 142 +++ .../apache/zest/gradle/RootProjectPlugin.groovy | 259 +++++ .../org/apache/zest/gradle/ZestExtension.groovy | 2 + .../org/apache/zest/gradle/ZestPlugin.groovy | 32 - .../dependencies/DependenciesPlugin.groovy | 346 ++++++ .../zest/gradle/dist/DistributionPlugin.groovy | 375 +++++++ .../gradle/dist/GoOfflineHelpersTasks.groovy | 345 ++++++ .../gradle/doc/AsciidocBuildInfoPlugin.groovy | 3 +- .../zest/gradle/doc/DocumentationTask.groovy | 6 +- .../zest/gradle/publish/MavenMetadata.groovy | 281 +++++ .../zest/gradle/publish/PublishingPlugin.groovy | 181 ++++ .../gradle/release/CheckReleaseSpecTask.groovy | 75 ++ .../release/ReleaseApprovedProjectsTask.groovy | 57 + .../gradle/release/ReleaseSpecExtension.groovy | 40 + .../gradle/release/ReleaseSpecPlugin.groovy | 60 ++ .../apache/zest/gradle/tasks/ExecLogged.groovy | 94 ++ .../test/AggregatedJacocoReportTask.groovy | 91 ++ .../gradle/version/VersionClassPlugin.groovy | 10 +- libraries.gradle | 291 ----- maven-compat.gradle | 283 ----- 23 files changed, 2548 insertions(+), 1619 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/56793996/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index cc78501..df33a55 100644 --- a/build.gradle +++ b/build.gradle @@ -14,1010 +14,9 @@ * 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. - * - * */ -import org.apache.tools.ant.filters.ReplaceTokens -import org.apache.zest.gradle.ZestPlugin -import org.apache.zest.gradle.doc.AsciidocBuildInfoPlugin -import org.apache.zest.gradle.release.ModuleReleaseSpec -import org.apache.zest.gradle.version.VersionClassPlugin - -allprojects { - apply plugin: ZestPlugin -} - -project.ext { - title = "Apache Zest⢠(Java Edition) SDK" - description = "Apache Zest⢠(Java Edition) is a framework for domain centric application development, including evolved concepts from AOP, DI and DDD." -} - -buildscript { - repositories { - maven { url "https://plugins.gradle.org/m2/" } - jcenter() - } - dependencies { - classpath 'gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.2' - classpath 'gradle.plugin.org.nosphere.honker:honker-gradle:0.2.3' - classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1' - } -} - - -apply plugin: 'java' -apply plugin: 'signing' -apply plugin: 'maven' -apply plugin: 'maven-publish-auth' -apply plugin: 'project-report' -apply from: 'libraries.gradle' -apply plugin: 'org.nosphere.apache.rat' - -targetCompatibility = "1.8" -sourceCompatibility = "1.8" - -// Collect the modules that fulfills the Release Criteria. -project.ext { - releaseSpec = new ModuleReleaseSpec() - releaseApprovedProjects = allprojects.findAll( { p -> rootProject.releaseSpec.satisfiedBy( p ) } ) -} - -// Toggle signing, used by the source distribution by setting the skipSigning property in gradle.properties -project.ext.skipSigning = rootProject.hasProperty( 'skipSigning' ) ? rootProject.skipSigning : false - -rat { - onlyIf { version != '0' } - excludes = [ - '**/.DS_Store/**', '**/._*', - // Git Files - '**/.git/**', '**/.gitignore', - // Gradle Files - 'gradle/wrapper/**', '**/gradlew', '**/gradlew.bat', '**/.gradle/**', - // Build Output - '**/build/**', '**/derby.log', 'out/**', - // IDE Files - '**/.idea/**', '**/*.iml', '**/*.ipr', '**/*.iws', - '**/.settings/**', '**/.classpath', '**/.project', - '**/.gradletasknamecache', '**/private/cache/**', - '**/.nb-gradle-properties', '**/.nb-gradle/**', - // JSON files are not allowed to have comments, according to http://www.json.org/ and http://www.ietf.org/rfc/rfc4627.txt - '**/*.json', - // Various Text Resources - '**/README.*','**/README*.*', '**/TODO', - '**/src/main/resources/**/*.txt', - '**/src/test/resources/**/*.txt', - 'libraries/rest-server/src/main/resources/**/*.htm', - 'libraries/rest-server/src/main/resources/**/*.atom', - 'tools/qidea/src/main/resources/**/*.ft', - 'tools/qidea/src/main/resources/**/*.template', - // Graphic Resources - '**/*.svg', '**/*.gif', '**/*.png', '**/*.jpg', '**/*.psd', - // Keystores - '**/*.jceks', - // Syntax Highlighter - MIT - 'manual/**/sh*.css', 'manual/**/sh*.js', - // jQuery & plugins - MIT - 'manual/**/jquery*.js', - // W3C XML Schemas - W3C Software License - 'samples/rental/src/main/resources/*.xsd', - // Zest Generator Heroes Templates - MIT - 'tools/generator-zest/app/templates/Heroes/**', - // templates that will become the user's source files, should not have license headers - 'tools/shell/src/dist/etc/templates/**', - ] -} - -// Define repositories URLs here so we can reuse them in the build script -// Needed as Gradle forbid access to declared repositories URLs by design -// Releasable submodules should not declare repositories in their own build files -def repos_urls = [ - mavenCentral: "https://repo1.maven.org/maven2/", - ops4j: "http://repository.ops4j.org/maven2/", - restlet: 'https://maven.restlet.com/', - clojars: "https://clojars.org/repo/", -] allprojects { - - apply plugin: 'signing' - apply plugin: 'java' -// apply plugin: 'checkstyle' - apply plugin: 'project-report' - apply plugin: 'maven' - apply plugin: 'org.nosphere.honker' - - - defaultTasks 'classes', 'test' - - group = name == 'org.apache.zest' ? 'org.apache.zest' : name.substring( 0, name.lastIndexOf( '.' ) ) - if( version == 'unspecified' ) { - version = System.properties.version ?: "0" - } - - // UTF-8 For all compilations and javadocs - // Deprecation warnings for all compilations - // Unchecked warnings for non-test core compilations - tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' - options.compilerArgs << "-Xlint:deprecation" - } - if("core".equals(group)) { - tasks.matching({ task -> task instanceof JavaCompile && !task.name.contains('test') }). - each({ task -> task.options.compilerArgs << "-Xlint:unchecked" }) - } - tasks.withType(Javadoc) { - options.encoding = 'UTF-8' - options.docEncoding = 'UTF-8' - options.charSet = 'UTF-8' - options.noTimestamp = true - options.links = [ - 'http://docs.oracle.com/javase/8/docs/api/', - 'https://stleary.github.io/JSON-java/', - 'http://junit.org/junit4/javadoc/latest/' - ] - // exclude '**/internal/**' - } - - repositories { - mavenCentral() - maven { name 'ops4j-repo'; url repos_urls.ops4j } - maven { name 'restlet-repo'; url repos_urls.restlet } - maven { name 'clojars-repo'; url repos_urls.clojars } - } - - // Artifact upload global configuration BEGIN ----------------------------- - - def uploadSnapshots = version.contains("SNAPSHOT") - def uploadReleases = ! uploadSnapshots - // By default RELEASES are signed, SNAPSHOTS are not - // Signing can be turned on or off by setting the uploadSigned property - def uploadSigned = rootProject.hasProperty('uploadSigned') \ - ? rootProject.uploadSigned : uploadReleases \ - ? true : false - // By default RELEASES must satisfy ReleaseSpecification, SNAPSHOT don't - // ReleaseSpecification usage can be turned on or off by setting the uploadReleaseSpec property - def uploadReleaseSpec = rootProject.hasProperty('uploadReleaseSpec') \ - ? rootProject.uploadReleaseSpec : uploadReleases \ - ? true : false - // By default RELEASES and SNAPSHOTS are uploaded using HTTP - // Used Wagon can be overriden by setting the uploadWagon property - // def wagonSSH = "org.apache.maven.wagon:wagon-ssh:2.2" - // def wagonWEBDAV = "org.apache.maven.wagon:wagon-webdav:1.0-beta-2" - def wagonHTTP = "org.apache.maven.wagon:wagon-http:2.2" - def uploadWagon = rootProject.hasProperty('uploadWagon') \ - ? rootProject.uploadWagon : wagonHTTP - // By default RELEASES and SNAPSHOTS are uploaded to Apache Nexus - // Target repository can be overriden by setting the uploadRepository property - def releasesRepositoryName = "apache.releases.https" - def releasesRepository = "https://repository.apache.org/service/local/staging/deploy/maven2" - def snapshotsRepositoryName = "apache.snapshots.https" - def snapshotsRepository = "https://repository.apache.org/content/repositories/snapshots" - def uploadRepositoryName = rootProject.hasProperty('uploadRepositoryName') \ - ? rootProject.uploadRepositoryName \ - : uploadReleases ? releasesRepositoryName : snapshotsRepositoryName - def uploadRepository = rootProject.hasProperty('uploadRepository') \ - ? rootProject.uploadRepository \ - : uploadReleases ? releasesRepository : snapshotsRepository - // No username/password is provided by default - // If needed set them using the uploadUsername and uploadPassword properties - def uploadUsername = rootProject.hasProperty('uploadUsername') ? rootProject.uploadUsername : null - def uploadPassword = rootProject.hasProperty('uploadPassword') ? rootProject.uploadPassword : null - - // Artifact upload global configuration END ------------------------------- - - - configurations { - archives - deployerJars - } - - dependencies { - testCompile( libraries.ant ) - testCompile( libraries.ant_junit ) - testCompile( libraries.junit ) - testCompile( libraries.hamcrest ) - testRuntime( libraries.asm, libraries.asm_commons, libraries.asm_util ) - deployerJars( uploadWagon ) - } - - test.onlyIf { !project.hasProperty( 'skipTests' ) } - test { - testLogging { - info { - exceptionFormat "full" - } - } - } - - sourceSets { - main { - output.dir( honkerGenDependencies.outputDir, builtBy: honkerGenDependencies ) - output.dir( honkerGenLicense.outputDir, builtBy: honkerGenLicense ) - output.dir( honkerGenNotice.outputDir, builtBy: honkerGenNotice ) - } - docs { - resources { - srcDir 'src/docs' - } - } - } - - honker { - // Project License, applied to all submodules - license 'Apache 2' - // Dependencies (transitive or not) with no license information, overriding them - licenseOverride { candidate -> - if( candidate.group == 'asm' || candidate.module == 'prefuse-core' ) { - candidate.license = 'BSD 3-Clause' - } - if( candidate.group == 'javax.websocket' ) { - candidate.license = 'CDDL' - } - if( candidate.group == 'org.apache.httpcomponents' - || candidate.group == 'net.java.dev.jna' - || candidate.group == 'lucene' - || candidate.group == 'jdbm' - || candidate.group == 'org.osgi' - || candidate.group.startsWith( 'org.restlet' ) ) { - candidate.license = 'Apache 2' - } - } - } - honkerGenNotice { - header = 'Apache Zest' - footer = 'This product includes software developed at\nThe Apache Software Foundation (http://www.apache.org/).\n' - } - check.dependsOn honkerCheck - - project.ext { - javaDir = new File( "$projectDir/src/main/java" ) - scalaDir = new File( "$projectDir/src/main/scala" ) - groovyDir = new File( "$projectDir/src/main/groovy") - documentationDir = new File( "$projectDir/src/docs" ) - testJavaDir = new File( "$projectDir/src/tests/java" ) - testScalaDir = new File( "$projectDir/src/tests/scala" ) - testGroovyDir = new File( "$projectDir/src/tests/groovy") - } - - // Actual code projects BEGIN ------------------------------------------- - if( ext.javaDir.isDirectory() || ext.scalaDir.isDirectory() || ext.groovyDir.isDirectory() || - ext.testJavaDir.isDirectory() || ext.testScalaDir.isDirectory() || ext.testGroovyDir.isDirectory() ) - { - // ZEST-175 - if( JavaVersion.current() < JavaVersion.VERSION_1_9 ) { - apply plugin: 'jacoco' - } - apply plugin: 'osgi' - apply plugin: VersionClassPlugin - apply plugin: AsciidocBuildInfoPlugin - -// if( name == "org.apache.zest.core.runtime" ) -// { -// checkstyleMain { -// configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-runtime-checkstyle.xml" ) -// ignoreFailures = true -// } -// } -// else -// { -// checkstyleMain { -// configFile = new File( rootProject.projectDir.absolutePath.toString() + '/etc/zest-api-checkstyle.xml' ) -// ignoreFailures = true -// reporting.baseDir = "$rootProject.reporting.baseDir/checkstyle" -// } -// } -// checkstyleTest { -// configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-tests-checkstyle.xml" ) -// ignoreFailures = true -// } -// -// checkstyleVersion { -// configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-tests-checkstyle.xml" ) -// ignoreFailures = true -// } - - jar { - manifest { - license = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - docURL = 'https://zest.apache.org' - description = project.description ?: 'Apache Zest⢠(Java Edition) is a platform for Composite Oriented Programming' - vendor = 'The Apache Software Foundation, https://www.apache.org' - instruction '-debug', 'true' - } - } - - signing { - required { rootProject.version != '0' && uploadSigned } - sign configurations.archives - } - signArchives.onlyIf { !rootProject.skipSigning } - - task sourceJar( type: Jar ) { - classifier = "sources" - from sourceSets.main.allSource - } - - task testSourceJar( type: Jar ) { - classifier = "testsources" - from sourceSets.test.allSource - } - - task javadocJar( type: Jar ) { - classifier = "javadoc" - from javadoc.destinationDir - dependsOn javadoc - } - - artifacts { - archives sourceJar, testSourceJar, javadocJar - } - - def testProperties = [ - 'proxySet': System.properties[ 'proxySet' ], - 'proxyHost': System.properties[ 'proxyHost' ], - 'proxyPort': System.properties[ 'proxyPort' ] ] - - test { - maxHeapSize = "1024m" - systemProperties = testProperties - systemProperties['user.dir'] = workingDir // GRADLE-2859 - reports.html.enabled(true) - } - // ZEST-175 - if(JavaVersion.current() < JavaVersion.VERSION_1_9 ) { - jacoco { - toolVersion = '0.7.5.201505241946' - } - } - -// // Create checkstyle report -// task checkstyleReport( type: XsltTask, dependsOn: check ) { -// source project.checkstyle.reportsDir -// include '*.xml' -// destDir = file( "build/reports/checkstyle/" ) -// extension = 'html' -// stylesheetFile = file( "$rootProject.projectDir/etc/checkstyle-noframes.xsl" ) -// } -// - - // Dependency Report generate only the runtime configuration - // The report is packaged in the SDK distributions - dependencyReport { - configurations = [ project.configurations.runtime ] - } - - } - // Actual code projects END --------------------------------------------- - - // Upload Archives - Artifact Deployment - uploadArchives.doFirst { - if( version == "0" ) - { - throw new GradleException( "'version' must be given as a system property to perform a release." ) - } - } - - uploadArchives.onlyIf { ( !uploadReleaseSpec || ( releaseApprovedProjects.contains( project ) || project == rootProject ) ) && !project.hasProperty( 'skipUpload' ) } - uploadArchives { - dependsOn check - repositories.mavenDeployer { - if( uploadSigned ) - beforeDeployment { MavenDeployment deployment -> signing.signPom( deployment ) } - configuration = configurations.deployerJars - repository(id: uploadRepositoryName, url: uploadRepository) { - if( uploadUsername ) - authentication(userName: uploadUsername, password: uploadPassword) - } - snapshotRepository(id: uploadRepositoryName, url: uploadRepository) { - if( uploadUsername ) - authentication(userName: uploadUsername, password: uploadPassword) - } - } - } - apply from: "$rootProject.projectDir/maven-compat.gradle" - apply plugin: 'maven-publish-auth' // Bug in maven-publish-auth require apply after uploadArchives setup - -} // allprojects END ------------------------------------------------------- - -// Allow easy download of all dependencies to go offline -// ./gradlew goOffline -task goOffline { - doLast { - allprojects.configurations.flatten()*.resolvedConfiguration - } -} - -task globalTestReport( type: TestReport ) { - destinationDir = file("$buildDir/reports/tests") - reportOn subprojects*.test -} - -test { - dependsOn subprojects*.test, globalTestReport - reports.html.enabled = false -} - -// Jacoco -configurations { - jacoco -} -dependencies { - jacoco 'org.jacoco:org.jacoco.ant:0.7.5.201505241946' -} -// Generate a global code codeverage report -task coverageReport { - // ZEST-175 - enabled = JavaVersion.current() < JavaVersion.VERSION_1_9 - dependsOn subprojects*.test - def outputPath = "build/reports/coverage" - inputs.dir subprojects.collect { p -> "${p.buildDir.path}/jacoco" } - outputs.dir outputPath - doLast { - def coveredProjects = subprojects.findAll { p -> new File( "${p.buildDir.path}/jacoco" ).exists() } - def coreProjects = coveredProjects.findAll { p -> p.name.startsWith('org.apache.zest.core' ) } - def libProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.lib' ) } - def extProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.ext' ) } - def toolsProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.tool' ) } - def tutoProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.tuto' ) } - def samplesProjects = coveredProjects.findAll { p -> p.name.startsWith( 'org.apache.zest.sample' ) } - ant { - taskdef name:'jacocoreport', classname: 'org.jacoco.ant.ReportTask', classpath: configurations.jacoco.asPath - mkdir dir: outputPath - jacocoreport { - executiondata { - coveredProjects.collect { p -> fileset( dir: "${p.buildDir.path}/jacoco" ) { include( name: '*.exec' ) } } - } - structure( name: "Apache Zest⢠(Java Edition) SDK" ) { - group( name: "Core" ) { - classfiles { coreProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } } - sourcefiles { coreProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } } - } - group( name: "Libraries" ) { - classfiles { libProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } } - sourcefiles { libProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } } - } - group( name: "Extensions" ) { - classfiles { extProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } } - sourcefiles { extProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } } - } - group( name: "Tools" ) { - classfiles { toolsProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } } - sourcefiles { toolsProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } } - } - group( name: "Tutorials" ) { - classfiles { tutoProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } } - sourcefiles { tutoProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } } - } - group( name: "Samples" ) { - classfiles { samplesProjects.collect { p -> fileset dir: "${p.buildDir.path}/classes/main" } } - sourcefiles { samplesProjects.collect { p -> fileset dir: "${p.projectDir.path}/src/main/java" } } - } - } - csv destfile: "${outputPath}/jacoco.csv", encoding: "UTF-8" - xml destfile: "${outputPath}/jacoco.xml", encoding: "UTF-8" - html destdir: outputPath, encoding: "UTF-8", locale: "en", footer: "Apache Zest⢠(Java Edition) SDK" - } - } - } -} -check.dependsOn coverageReport - - -// Build the whole SDK public Javadoc -task javadocs( type: Javadoc ) { - - options.docFilesSubDirs = true - options.encoding = "UTF-8" - options.overview = "${rootProject.projectDir}/src/javadoc/overview.html" - title = "${rootProject.title} ${version}" - def apiSources = releaseApprovedProjects.findAll( { project -> - ( project.name.startsWith( 'org.apache.zest.core' ) && !project.name.startsWith( 'org.apache.zest.core.runtime' ) ) || - project.name.startsWith( 'org.apache.zest.library' ) || - project.name.startsWith( 'org.apache.zest.extension' ) || - project.name.startsWith( 'org.apache.zest.tool' ) - } ) - source apiSources.collect { project -> - project.sourceSets.main.allJava - } - destinationDir = project.file( "$project.docsDir/javadocs" ) - // Might need a classpath - classpath = files( apiSources.collect { project -> - project.sourceSets.main.compileClasspath - } ) - options.group( [ "Core API": [ "org.apache.zest.api", "org.apache.zest.api.*", "org.apache.zest.io", "org.apache.zest.functional" ], - "Core Bootstrap": [ "org.apache.zest.bootstrap", "org.apache.zest.bootstrap.*" ], - "Core SPI": [ "org.apache.zest.spi", "org.apache.zest.spi.*" ], - "Libraries": [ "org.apache.zest.library.*" ], - "Extensions": [ "org.apache.zest.valueserialization.*", "org.apache.zest.entitystore.*", "org.apache.zest.index.*", "org.apache.zest.metrics.*", "org.apache.zest.cache.*", "org.apache.zest.migration", "org.apache.zest.migration.*" ], - "Tools": [ "org.apache.zest.tools.*", "org.apache.zest.envisage", "org.apache.zest.envisage.*" ], - "Test Support": [ "org.apache.zest.test", "org.apache.zest.test.*" ] - ] ) - -} - -task archiveJavadocs(type: Copy ) { - dependsOn javadocs - - if( rootProject.version == '0' || rootProject.version.contains( "SNAPSHOT" ) ) - { - into( "$rootProject.projectDir/../zest-web/site/content/java/develop/javadocs/" ) - } - else - { - into( "$rootProject.projectDir/../zest-web/site/content/java/$version/javadocs/" ) - } - from( 'build/docs/javadoc/' ) -} - - -// Build All -task buildAll( dependsOn: [ - javadocs, - check, - jar, - subprojects*.dependencyReport, - subprojects*.assemble, - ':org.apache.zest.manual:website' -] ) { } - -// Generate license headers with comment styles -def licenseHeader_wrap( base, top, left, bottom ) { - ( top ? "$top\n" : '' ) + base.readLines().collect{ "${left}${it}" }.join( '\n' ) + '\n' + ( bottom ? "$bottom\n" : '' ) -} -def licenseHeader( flavour ) { - def base = project.file( 'etc/header.txt' ).text - def header - switch( flavour ) { - case 'java': case 'groovy': case 'scala': case 'js': - header = licenseHeader_wrap( base, '/*', ' * ', ' */' ) ; break - case 'xml': case 'html': - header = licenseHeader_wrap( base, '<!--', ' ', '-->' ) ; break - case 'txt': case 'shell': case 'python': case 'ruby': - header = licenseHeader_wrap( base, null, '# ', null ) ; break - case 'adoc': case 'asciidoc': - header = licenseHeader_wrap( base, null, '// ', null ) ; break - default: - header = base - } - header -} - -task generateBinDistGoOfflineHelpers { - def goOfflineGradleFile = file( 'build/go-offline-helpers/go-offline.gradle' ) - def goOfflinePomFile = file( 'build/go-offline-helpers/go-offline.pom') - outputs.file goOfflineGradleFile - outputs.file goOfflinePomFile - doLast { - - def goOfflineGradle = licenseHeader( 'java' ) - goOfflineGradle += '// This gradle build file has the sole purpose of downloading all dependencies in a directory relative to this file named \'dependencies\'.\n' - goOfflineGradle += '// Use the following command: gradle -b go-offline.gradle download\n' - goOfflineGradle += 'apply plugin: \'java\'\nconfigurations { download }\nrepositories {\n' - def goOfflinePom = licenseHeader( 'xml' ) - goOfflinePom += '<project>\n <modelVersion>4.0.0</modelVersion>\n' - goOfflinePom += " <groupId>org.apache.zest</groupId>\n <artifactId>go-offline-helper</artifactId>\n <version>$version</version>\n" - goOfflinePom += ' <packaging>pom</packaging>\n' - goOfflinePom += ' <!--\n This pom has the sole purpose of downloading all dependencies in a directory relative to this file named \'dependencies\'.\n' - goOfflinePom += ' Use the following command:\n\n mvn -f go-offline.pom validate\n -->\n <repositories>\n' - - def repoCount = 1 - repos_urls.each { repo_url -> - goOfflineGradle += " maven { url '${repo_url.value}' }\n" - goOfflinePom += " <repository><id>go-offline-repo-$repoCount</id><url>${repo_url.value}</url></repository>\n" - repoCount++ - } - - goOfflineGradle += '}\ndependencies {\n' - goOfflinePom += ' </repositories>\n <dependencies>\n' - - // Do the global dependency resolution here so there won't be any suprise when using the helpers - // This also allow to apply the resolution strategy defined in libraries.gradle - // WARN some of our modules depends on != versions of some artifacts, this resolution flatten this using the most up to date - def allRuntimeDeps = releaseApprovedProjects.collect{ it.configurations.runtime.allDependencies }.flatten() - rootProject.configurations.create( 'goOfflineHelpers' ) - rootProject.dependencies { allRuntimeDeps.each{ goOfflineHelpers it } } - rootProject.configurations.goOfflineHelpers.incoming.resolutionResult.allComponents.each { comp -> - def depCoords = "${comp.moduleVersion.group}:${comp.moduleVersion.name}:${comp.moduleVersion.version}" - if( !comp.moduleVersion.group.startsWith( 'org.apache.zest' ) ) { - goOfflineGradle += " download( '$depCoords' ) { transitive = false }\n" - goOfflinePom += " <dependency><groupId>${comp.moduleVersion.group}</groupId><artifactId>${comp.moduleVersion.name}</artifactId><version>${comp.moduleVersion.version}</version></dependency>\n" - } - } - - goOfflineGradle += """} -task download( type: Copy ) { - def sources = configurations.download.resolvedConfiguration.resolvedArtifacts.collect { artifact -> - project.dependencies.create( [ group: artifact.moduleVersion.id.group, name: artifact.moduleVersion.id.name, version: artifact.moduleVersion.id.version, classifier: 'sources' ] ) - } - def javadocs = configurations.download.resolvedConfiguration.resolvedArtifacts.collect { artifact -> - project.dependencies.create( [ group: artifact.moduleVersion.id.group, name: artifact.moduleVersion.id.name, version: artifact.moduleVersion.id.version, classifier: 'javadoc' ] ) - } - from configurations.download - from configurations.detachedConfiguration( sources as Dependency[] ).resolvedConfiguration.lenientConfiguration.getFiles( Specs.SATISFIES_ALL ) - from configurations.detachedConfiguration( javadocs as Dependency[] ).resolvedConfiguration.lenientConfiguration.getFiles( Specs.SATISFIES_ALL ) - into file( 'dependencies/' ) -} -""" - - goOfflinePom += """ </dependencies>\n <build><plugins><plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <version>2.10</version> - <executions> - <execution> - <id>go-offline-jars</id><phase>validate</phase> - <goals><goal>copy-dependencies</goal></goals> - <configuration> - <outputDirectory>\${project.basedir}/dependencies</outputDirectory> - <excludeTransitive>true</excludeTransitive> - </configuration> - </execution> - <execution> - <id>go-offline-sources</id><phase>validate</phase> - <goals><goal>copy-dependencies</goal></goals> - <configuration> - <classifier>sources</classifier><failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact> - <outputDirectory>\${project.basedir}/dependencies</outputDirectory> - <excludeTransitive>true</excludeTransitive> - </configuration> - </execution> - <execution> - <id>go-offline-javadocs</id><phase>validate</phase> - <goals><goal>copy-dependencies</goal></goals> - <configuration> - <classifier>javadoc</classifier><failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact> - <outputDirectory>\${project.basedir}/dependencies</outputDirectory> - <excludeTransitive>true</excludeTransitive> - </configuration> - </execution> - </executions> - </plugin></plugins></build> -</project> -""" - - goOfflineGradleFile.parentFile.mkdirs() - goOfflinePomFile.parentFile.mkdirs() - - goOfflineGradleFile.text = goOfflineGradle - goOfflinePomFile.text = goOfflinePom - } -} - - -def srcDistFilesImages = copySpec { - from '.' - include '*.txt' - include 'doap.rdf' - include '*.gradle' - include 'gradlew*' - include 'gradle/**' - include 'etc/**' - include 'buildSrc/**' - include 'src/**' - releaseApprovedProjects.each { p -> - def relPath = new File( project.projectDir.toURI().relativize( p.projectDir.toURI() ).toString() ) - include "$relPath/**" - } - include 'manual/**' - include 'samples/**' - include 'tests/**' - include 'tutorials/**' - include 'tools/shell/**' - // Filtered, see below - exclude 'settings.gradle' - exclude 'gradle.properties' - // Excludes - exclude '**/build/' // Build output - exclude 'derby.log' // Derby test garbage - exclude '**/*.iml' // IDEA files - exclude '**/*.ipr' // IDEA files - exclude '**/*.iws' // IDEA files - exclude '**/.idea' // IDEA files - exclude '**/out/*' // IDEA build output - exclude '**/.classpath' // Eclipse files - exclude '**/.project' // Eclipse files - exclude '**/.settings' // Eclipse files - exclude '**/.nb-gradle/' // Netbeans files - exclude '**/.nb-gradle*' // Netbeans files - exclude '**/.git/' // Git directories - exclude '**/.git*' // Git files - exclude '**/.gradle/' // Gradle management files - exclude '**/.gradletasknamecache' // Gradle cache - into '.' -} - -task srcDistFilteredFiles() { - // Generates various files for the source distribution - // - settings.gradle - // - gradle.properties to set version ! - def filteredDir = new File( "$project.buildDir/tmp/srcDistFilteredFiles") - outputs.file filteredDir - doLast { - // Settings - def settingsFile = new File( filteredDir, 'settings.gradle' ) - settingsFile.parentFile.mkdirs() - def filteredSettings = '' - project.file( 'settings.gradle' ).readLines().each { line -> - if( line.contains( '\'libraries:' ) || line.contains( '\'extensions:' ) || line.contains( '\'tools:' ) ) { - def accepted = false - releaseApprovedProjects.collect{it.projectDir}.each { acceptedProjectDir -> - if( line.contains( "'${acceptedProjectDir.parentFile.name}:${acceptedProjectDir.name}'" ) ) { - accepted = true - } - } - if( accepted ) { - filteredSettings += "$line\n" - } - } else { - filteredSettings += "$line\n" - } - } - settingsFile.text = filteredSettings - // gradle.properties - def gradlePropsFile = new File( filteredDir, 'gradle.properties' ) - gradlePropsFile.parentFile.mkdirs() - gradlePropsFile.text = project.file( 'gradle.properties' ).text + "\nskipSigning=true\nskipAsciidocIfAbsent=true\n\nversion=$version\n" - } -} - -def srcDistFilteredFilesImage = copySpec { - from srcDistFilteredFiles - into '.' -} - -def srcDistImage = copySpec { - into "apache-zest-java-$version-src" - with srcDistFilesImages - with srcDistFilteredFilesImage -} - -def reportsDistImage = copySpec { - from "$buildDir/reports" - into( "docs/reports" ) -} - -def docsImage = copySpec { - from "build/docs" - from "manual/build/docs/website" - into( "docs" ) -} - -def runtimeDependenciesListImage = copySpec { - releaseApprovedProjects.collect { p -> - into( "libs/" ) { - from "$p.buildDir/reports/project/dependencies.txt" - rename 'dependencies.txt', "${p.name}-${p.version}-runtime-deps.txt" - } - } - into( '.' ) { - from generateBinDistGoOfflineHelpers.outputs - } -} - -def libsImage = copySpec { - releaseApprovedProjects.collect { proj -> - into( "libs/" ) { - from proj.configurations.archives.artifacts.files - exclude '**-testsources.jar' - exclude '**/*.asc' - } - } -} - -def extraDistTextImage = copySpec { - releaseApprovedProjects.collect { p -> - from fileTree(dir: "$p.projectDir/src/dist/", include: '**', exclude: "**/*.jar*") - eachFile { - filter(ReplaceTokens, tokens: [version: version]) - } - } - into( "." ) -} - -def extraDistBinImage = copySpec { - releaseApprovedProjects.collect { p -> - from "$p.projectDir/src/dist/" - include "**/*.jar" - include "**/*.jar_" - } - into( "." ) -} - -def binDistNoticesImage = copySpec { - from( "$projectDir/LICENSE.txt") - from( "$projectDir/src/bin-dist" ) - into( "." ) -} - -def binDistImage = copySpec { - into "apache-zest-java-$version-bin" - with binDistNoticesImage - with docsImage - with reportsDistImage - with runtimeDependenciesListImage - with extraDistTextImage - with extraDistBinImage - with libsImage -} - -task zipSources( type: Zip ) { - baseName = 'apache-zest-java' - with srcDistImage - classifier = 'src' -} - -task tarSources( type: Tar ) { - baseName = 'apache-zest-java' - with srcDistImage - compression = Compression.GZIP - classifier = 'src' -} - -task zipBinaries( type: Zip, dependsOn: buildAll ) { - baseName = 'apache-zest-java' - classifier = 'bin' - with binDistImage -} - -task tarBinaries( type: Tar, dependsOn: buildAll ) { - baseName = 'apache-zest-java' - classifier = 'bin' - compression = Compression.GZIP - with binDistImage -} - -// Checksum distributions -tasks.withType( Zip ) { task -> - task.doLast { - ant.checksum file: task.archivePath, algorithm: 'MD5' - ant.checksum file: task.archivePath, algorithm: 'SHA-512' - } -} -tasks.withType( Tar ) { task -> - task.doLast { - ant.checksum file: task.archivePath, algorithm: 'MD5' - ant.checksum file: task.archivePath, algorithm: 'SHA-512' - } -} - -artifacts { - archives zipSources, tarSources, zipBinaries, tarBinaries -} - -signing { - required { rootProject.version != '0' && !rootProject.version.contains( 'SNAPSHOT' ) } - sign configurations.archives -} -signArchives.onlyIf { !rootProject.skipSigning } - -task dist( type: Copy, dependsOn: install ) { - description "Unpack the binary distribution" - group = "distributions" - with binDistImage - into "$buildDir/dist" -} - -// Tasks for source and binary distributions checks -def unpackedSrcDistDir = file( "build/unpacked-distributions/src/apache-zest-java-$version-src" ) -def unpackedBinDistDir = file( "build/unpacked-distributions/bin/apache-zest-java-$version-bin" ) -task unpackSrcDist( type: Copy ) { - description "Unpack the source distribution" - group = "distributions" - with srcDistImage - into 'build/unpacked-distributions/src' -} -task checkSrcDist( type: GradleBuild, dependsOn: unpackSrcDist ) { - description = "Check the source distribution by running the 'check' and 'assemble' tasks inside" - group = "distributions" - buildFile = "$unpackedSrcDistDir/build.gradle" - tasks = [ 'check', 'assemble' ] -} -task unpackBinDist( type: Copy, dependsOn: buildAll ) { - description "Unpack the binary distribution" - group = "distributions" - with binDistImage - into 'build/unpacked-distributions/bin' -} -task checkBinDist_rat( type: org.apache.rat.gradle.RatTask, dependsOn: unpackBinDist ) { - description "Check the binary distribution using Apache RAT" - group = "distributions" - inputDir = unpackedBinDistDir - reportDir = file( 'build/reports/rat-bin-dist' ) - excludes = [] -} -task checkBinDist_goOfflineGradle( type: GradleBuild, dependsOn: unpackBinDist ) { - description "Check the binary distribution Gradle go-offline helper" - group = "distributions" - def dependenciesDir = new File( unpackedBinDistDir, 'dependencies' ) - doFirst { dependenciesDir.deleteDir() } - buildFile = "$unpackedBinDistDir/go-offline.gradle" - tasks = [ 'download' ] - doLast { - releaseApprovedProjects*.configurations.runtime.allDependencies.findAll({it.name}).each { dep -> - def jarArtifactId = dep.name instanceof String ? dep.name : dep.name.last() - def jarVersion = dep.version instanceof String ? dep.version : dep.version.last() - if( !jarArtifactId.startsWith( 'org.apache.zest' ) ) { - def jarName = "${jarArtifactId}-${jarVersion}.jar" - if( !new File( dependenciesDir, jarName ).exists() ) { - throw new GradleException( "Binary distribution go-offline.gradle failed! Missing: $jarName" ); - } - } - } - } -} -task checkBinDist_goOfflineMaven( type: Exec, dependsOn: unpackBinDist ) { - description "Check the binary distribution Maven go-offline helper" - group = "distributions" - onlyIf { - def pathDirs = System.getenv( 'PATH' ).split( File.pathSeparator ) - pathDirs.collect( { new File( it, 'mvn') } ).flatten().findAll( { it.isFile() } ) - } - def dependenciesDir = new File( unpackedBinDistDir, 'dependencies' ) - doFirst { dependenciesDir.deleteDir() } - workingDir unpackedBinDistDir - commandLine 'mvn', '-e', '-f', 'go-offline.pom', 'validate' - doLast { - releaseApprovedProjects*.configurations.runtime.allDependencies.findAll({it.name}).each { dep -> - def jarArtifactId = dep.name instanceof String ? dep.name : dep.name.last() - def jarVersion = dep.version instanceof String ? dep.version : dep.version.last() - if( !jarArtifactId.startsWith( 'org.apache.zest' ) ) { - def jarName = "${jarArtifactId}-${jarVersion}.jar" - if( !new File( dependenciesDir, jarName ).exists() ) { - throw new GradleException( "Binary distribution go-offline.pom failed! Missing: $jarName" ); - } - } - } - } -} -task checkBinDist { - description "Check the binary distribution" - group = "distributions" - dependsOn /*checkBinDist_rat,*/ checkBinDist_goOfflineGradle, checkBinDist_goOfflineMaven -} -task checkDists { - description "Check the souce and binary distributions" - group = "distributions" - dependsOn checkSrcDist, checkBinDist -} - -task checkReleaseSpec { - description = "Ensure that no releasable module depend on module(s) that don't fit the release criteria." - group = 'release' - dependsOn releaseApprovedProjects*.configurations.runtime - doFirst { - def notReleasable = [:] - releaseApprovedProjects*.configurations.runtime.allDependencies.findAll({ it instanceof ProjectDependency }).each { dep -> - def depNotReleaseApproved = releaseApprovedProjects.findAll { rp -> - rp.group == dep.dependencyProject.group && rp.name == dep.dependencyProject.name - }.isEmpty() - if( depNotReleaseApproved ) - { - if( !notReleasable[p] ) notReleasable[p] = [] - notReleasable[p] << dep - } - } - if(!notReleasable.isEmpty()) { - def errorMessage = new StringBuilder() - errorMessage << "At least one releasable module depends on module(s) that don't fit the release criteria!\n" - errorMessage << "\tOffending module -> Non releasable dependencies\n" - notReleasable.each { k,v -> - def noRlsDeps = v.collect{d -> ':'+d.dependencyProject.group+':'+d.dependencyProject.name} - errorMessage << "\t$k -> ${noRlsDeps})\n" - } - errorMessage << "Check the dev-status.xml file content in each modules directory." - throw new GradleException( errorMessage.toString() ) - } - } -} - -task release { - description = 'Builds, tests and uploads the release artifacts' - group = 'release' - doFirst { - if( System.properties[ 'version' ] == null || System.properties[ 'version' ].contains( 'SNAPSHOT' ) ) - { - throw new GradleException( "'version' must be given as a system property to perform a release." ) - } - } - dependsOn checkReleaseSpec, rat, archiveJavadocs, ':org.apache.zest.manual:copyWebsite', allprojects*.uploadArchives, dist + apply plugin: org.apache.zest.gradle.AllProjectsPlugin } +apply plugin: org.apache.zest.gradle.RootProjectPlugin http://git-wip-us.apache.org/repos/asf/zest-java/blob/56793996/buildSrc/build.gradle ---------------------------------------------------------------------- diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 358922d..ff2dde8 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -17,3 +17,14 @@ * * */ + +repositories { + maven { url "https://plugins.gradle.org/m2/" } + jcenter() +} + +dependencies { + compile 'gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.2' + compile 'gradle.plugin.org.nosphere.honker:honker-gradle:0.2.3' + compile 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1' +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/56793996/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy new file mode 100644 index 0000000..bed6352 --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy @@ -0,0 +1,178 @@ +/* + * 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. + */ +package org.apache.zest.gradle + +import groovy.transform.CompileStatic +import org.apache.zest.gradle.dependencies.DependenciesPlugin +import org.apache.zest.gradle.publish.PublishingPlugin +import org.gradle.api.JavaVersion +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.tasks.compile.JavaCompile +import org.gradle.api.tasks.javadoc.Javadoc +import org.gradle.api.tasks.testing.Test +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.external.javadoc.StandardJavadocDocletOptions +import org.nosphere.honker.gradle.HonkerExtension +import org.nosphere.honker.gradle.HonkerGenDependenciesTask +import org.nosphere.honker.gradle.HonkerGenLicenseTask +import org.nosphere.honker.gradle.HonkerGenNoticeTask +import org.nosphere.honker.gradle.HonkerLicenseOverrideCandidate + +@CompileStatic +class AllProjectsPlugin implements Plugin<Project> +{ + @Override + void apply( final Project project ) + { + project.defaultTasks = [ 'classes', 'test' ] + project.group = project.name == 'org.apache.zest' ? + 'org.apache.zest' : + project.name.substring( 0, project.name.lastIndexOf( '.' ) ) + + applyVersionning( project ) + applyZestExtension( project ) + + configureJava( project ) + project.plugins.apply DependenciesPlugin + configureJavadoc( project ) + configureTest( project ) + if( CodeProjectsPlugin.isCodeProject( project ) ) + { + project.plugins.apply CodeProjectsPlugin + } + configureDependencyReport( project ) + configureHonker( project ) + project.plugins.apply PublishingPlugin + } + + private static void applyVersionning( Project project ) + { + if( project.version == 'unspecified' ) + { + project.version = System.properties.version ?: '0' + } + } + + private static void applyZestExtension( Project project ) + { + project.extensions.create( "zest", ZestExtension, project ) + } + + private static void configureJava( Project project ) + { + project.plugins.apply 'java' + def javaConvention = project.convention.getPlugin( JavaPluginConvention ) + javaConvention.targetCompatibility = JavaVersion.VERSION_1_8 + javaConvention.sourceCompatibility = JavaVersion.VERSION_1_8 + project.tasks.withType( JavaCompile ) { JavaCompile task -> + task.options.encoding = 'UTF-8' + // Deprecation warnings for all compilations + task.options.compilerArgs << "-Xlint:deprecation" + // Unchecked warnings for non-test core compilations + if( 'org.apache.zest.core' == project.group && !task.name.toLowerCase( Locale.US ).contains( 'test' ) ) + { + task.options.compilerArgs << "-Xlint:unchecked" + } + } + } + + private static void configureJavadoc( Project project ) + { + project.tasks.withType( Javadoc ) { Javadoc task -> + def options = task.options as StandardJavadocDocletOptions + options.encoding = 'UTF-8' + options.docEncoding = 'UTF-8' + options.charSet = 'UTF-8' + options.noTimestamp = true + options.links = [ + 'http://docs.oracle.com/javase/8/docs/api/', + 'https://stleary.github.io/JSON-java/', + 'http://junit.org/junit4/javadoc/latest/' + ] + // exclude '**/internal/**' + } + } + + private static void configureTest( Project project ) + { + def test = project.tasks.getByName( 'test' ) as Test + test.onlyIf { !project.hasProperty( 'skipTests' ) } + test.testLogging.info.exceptionFormat = TestExceptionFormat.FULL + test.maxHeapSize = '1g' + test.systemProperties = [ 'proxySet' : System.properties[ 'proxySet' ], + 'proxyHost': System.properties[ 'proxyHost' ], + 'proxyPort': System.properties[ 'proxyPort' ] ] + test.systemProperties[ 'user.dir' ] = test.workingDir + test.reports.html.enabled = true + } + + // Dependency Report generate only the runtime configuration + // The report is packaged in the SDK distributions + private static void configureDependencyReport( Project project ) + { + project.plugins.apply 'project-report' + // TODO Fails with no task found + // def dependencyReport = project.tasks.getByName( 'dependencyReport' ) as DependencyReportTask + // dependencyReport.configurations = [ project.configurations.getByName( 'runtime' ) ] as Set + } + + private static void configureHonker( Project project ) + { + project.plugins.apply 'org.nosphere.honker' + def honkerGenDependencies = project.tasks.getByName( 'honkerGenDependencies' ) as HonkerGenDependenciesTask + def honkerGenLicense = project.tasks.getByName( 'honkerGenLicense' ) as HonkerGenLicenseTask + def honkerGenNotice = project.tasks.getByName( 'honkerGenNotice' ) as HonkerGenNoticeTask + def javaConvention = project.convention.getPlugin( JavaPluginConvention ) + def mainSourceSet = javaConvention.sourceSets.getByName( 'main' ) + mainSourceSet.output.dir( [ builtBy: honkerGenDependencies ] as Map<String, Object>, + honkerGenDependencies.outputDir ) + mainSourceSet.output.dir( [ builtBy: honkerGenLicense ] as Map<String, Object>, + honkerGenLicense.outputDir ) + mainSourceSet.output.dir( [ builtBy: honkerGenNotice ] as Map<String, Object>, + honkerGenNotice.outputDir ) + def honker = project.extensions.getByType( HonkerExtension ) + // Project License, applied to all submodules + honker.license 'Apache 2' + // Dependencies (transitive or not) with no license information, overriding them + honker.licenseOverride { HonkerLicenseOverrideCandidate candidate -> + if( candidate.group == 'asm' || candidate.module == 'prefuse-core' ) + { + candidate.license = 'BSD 3-Clause' + } + if( candidate.group == 'javax.websocket' ) + { + candidate.license = 'CDDL' + } + if( candidate.group == 'org.apache.httpcomponents' + || candidate.group == 'net.java.dev.jna' + || candidate.group == 'lucene' + || candidate.group == 'jdbm' + || candidate.group == 'org.osgi' + || candidate.group.startsWith( 'org.restlet' ) ) + { + candidate.license = 'Apache 2' + } + } + honkerGenNotice.header = 'Apache Zest' + honkerGenNotice.footer = 'This product includes software developed at\n' + + 'The Apache Software Foundation (http://www.apache.org/).\n' + project.tasks.getByName( 'check' ).dependsOn project.tasks.getByName( 'honkerCheck' ) + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/56793996/buildSrc/src/main/groovy/org/apache/zest/gradle/CodeProjectsPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/CodeProjectsPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/CodeProjectsPlugin.groovy new file mode 100644 index 0000000..4517534 --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/CodeProjectsPlugin.groovy @@ -0,0 +1,142 @@ +/* + * 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. + */ +package org.apache.zest.gradle + +import groovy.transform.CompileStatic +import org.apache.zest.gradle.doc.AsciidocBuildInfoPlugin +import org.apache.zest.gradle.version.VersionClassPlugin +import org.gradle.api.JavaVersion +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.plugins.osgi.OsgiManifest +import org.gradle.api.tasks.javadoc.Javadoc +import org.gradle.jvm.tasks.Jar +import org.gradle.testing.jacoco.plugins.JacocoPluginExtension + +@CompileStatic +class CodeProjectsPlugin implements Plugin<Project> +{ + static boolean isCodeProject( Project project ) + { + [ 'src/main/java', 'src/test/java', + 'src/main/scala', 'src/test/scala', + 'src/main/groovy', 'src/test/groovy' ].collect { path -> + new File( "$project.projectDir/$path" ) + }.any { dir -> dir.isDirectory() } + } + + @Override + void apply( final Project project ) + { + project.plugins.apply VersionClassPlugin + project.plugins.apply AsciidocBuildInfoPlugin + + configureJar( project ) + configureSupplementaryArchives( project ) + + configureJacoco( project ) + configureCheckstyle( project ) + } + + private static void configureJar( Project project ) + { + project.plugins.apply 'osgi' + def jar = project.tasks.getByName( 'jar' ) as Jar + def manifest = jar.manifest as OsgiManifest + manifest.attributes( [ + license : 'http://www.apache.org/licenses/LICENSE-2.0.txt', + docURL : 'https://zest.apache.org/', + description: project.description ?: + 'Apache Zest⢠(Java Edition) is a platform for Composite Oriented Programming', + vendor : 'The Apache Software Foundation, https://www.apache.org', + ] ) + manifest.instruction '-debug', 'true' + } + + private static void configureSupplementaryArchives( Project project ) + { + def javaConvention = project.convention.getPlugin( JavaPluginConvention ) + def sourceJar = project.tasks.create( 'sourceJar', Jar ) { Jar task -> + task.classifier = 'sources' + task.from javaConvention.sourceSets.getByName( 'main' ).allSource + } + def testSourceJar = project.tasks.create( 'testSourceJar', Jar ) { Jar task -> + task.classifier = 'testsources' + task.from javaConvention.sourceSets.getByName( 'test' ).allSource + } + def javadoc = project.tasks.getByName( 'javadoc' ) as Javadoc + def javadocJar = project.tasks.create( 'javadocJar', Jar ) { Jar task -> + task.classifier = 'javadoc' + task.from javadoc.destinationDir + task.dependsOn javadoc + } + project.artifacts.add( 'archives', sourceJar ) + project.artifacts.add( 'archives', testSourceJar ) + project.artifacts.add( 'archives', javadocJar ) + } + + private static void configureJacoco( Project project ) + { + // ZEST-175 + if( JavaVersion.current() < JavaVersion.VERSION_1_9 ) + { + project.plugins.apply 'jacoco' + def jacoco = project.extensions.getByType( JacocoPluginExtension ) + jacoco.toolVersion = '0.7.5.201505241946' + } + } + + private static void configureCheckstyle( Project project ) + { + // project.plugins.apply 'checkstyle' + // if( name == "org.apache.zest.core.runtime" ) + // { + // checkstyleMain { + // configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-runtime-checkstyle.xml" ) + // ignoreFailures = true + // } + // } + // else + // { + // checkstyleMain { + // configFile = new File( rootProject.projectDir.absolutePath.toString() + '/etc/zest-api-checkstyle.xml' ) + // ignoreFailures = true + // reporting.baseDir = "$rootProject.reporting.baseDir/checkstyle" + // } + // } + // checkstyleTest { + // configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-tests-checkstyle.xml" ) + // ignoreFailures = true + // } + // + // checkstyleVersion { + // configFile = new File( "$rootProject.projectDir.absolutePath/etc/zest-tests-checkstyle.xml" ) + // ignoreFailures = true + // } + // // Create checkstyle report + // task checkstyleReport( type: XsltTask, dependsOn: check ) { + // source project.checkstyle.reportsDir + // include '*.xml' + // destDir = file( "build/reports/checkstyle/" ) + // extension = 'html' + // stylesheetFile = file( "$rootProject.projectDir/etc/checkstyle-noframes.xsl" ) + // } + // + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/56793996/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy new file mode 100644 index 0000000..b915cea --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy @@ -0,0 +1,259 @@ +/* + * 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. + */ +package org.apache.zest.gradle + +import groovy.transform.CompileStatic +import org.apache.rat.gradle.RatTask +import org.apache.zest.gradle.dist.DistributionPlugin +import org.apache.zest.gradle.release.ReleaseSpecExtension +import org.apache.zest.gradle.release.ReleaseSpecPlugin +import org.apache.zest.gradle.test.AggregatedJacocoReportTask +import org.gradle.api.GradleException +import org.gradle.api.JavaVersion +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.artifacts.Configuration +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.javadoc.Javadoc +import org.gradle.api.tasks.testing.Test +import org.gradle.api.tasks.testing.TestReport +import org.gradle.external.javadoc.StandardJavadocDocletOptions + +@CompileStatic +class RootProjectPlugin implements Plugin<Project> +{ + static final String PROJECT_TITLE = 'Apache Zest⢠(Java Edition) SDK' + static final String PROJECT_DESCRIPTION = 'Apache Zest⢠(Java Edition) is a framework for domain centric ' + + 'application development, including evolved concepts from AOP, DI and DDD.' + + static class TaskGroups + { + static final String HELPER_TASKS = 'Helper tasks' + static final String DOCUMENTATION = 'Documentation' + } + + static class TaskNames + { + static final String GO_OFFLINE = 'goOffline' + static final String GLOBAL_TEST_REPORT = 'globalTestReport' + static final String JAVADOCS = 'javadocs' + static final String ARCHIVE_JAVADOCS = 'archiveJavadocs' + static final String BUILD_ALL = 'buildAll' + } + + @Override + void apply( Project project ) + { + project.plugins.apply ReleaseSpecPlugin + + applyProjectMetadata( project ) + applyHelperTasks( project ) + applyPlugins( project ) + + configureJacoco( project ) + configureTestReport( project ) + configureJavadocs( project ) + configureRat( project ) + + project.plugins.apply DistributionPlugin + configureReleaseTask( project ) + } + + private static void applyProjectMetadata( Project project ) + { + def extraProperties = project.extensions.extraProperties + extraProperties.set 'title', PROJECT_TITLE + extraProperties.set 'description', PROJECT_DESCRIPTION + } + + private static void applyHelperTasks( Project project ) + { + project.tasks.create( TaskNames.GO_OFFLINE ) { Task task -> + task.group = TaskGroups.HELPER_TASKS + task.doLast { + def allConfigurations = project.allprojects.collect { Project each -> + each.configurations + }.flatten() as Set<Configuration> + allConfigurations*.resolvedConfiguration + } + } + def buildAll = project.tasks.create( TaskNames.BUILD_ALL ) + buildAll.dependsOn 'javadocs', 'check', 'jar', + project.subprojects.collect { p -> p.tasks.getByName( 'dependencyReport' ) }, + project.subprojects.collect { p -> p.tasks.getByName( 'assemble' ) }, + ':org.apache.zest.manual:website' + } + + private static void applyPlugins( Project project ) + { + project.plugins.apply 'org.nosphere.apache.rat' + } + + private static void configureJacoco( Project project ) + { + project.configurations.create( 'jacoco' ) + project.dependencies.add( 'jacoco', 'org.jacoco:org.jacoco.ant:0.7.5.201505241946' ) + def task = project.tasks.create( 'coverageReport', AggregatedJacocoReportTask ) { AggregatedJacocoReportTask task -> + // ZEST-175 + task.enabled = JavaVersion.current() < JavaVersion.VERSION_1_9 + task.dependsOn project.subprojects.collect( { Project p -> p.tasks.getByName( 'test' ) } ) + } + project.tasks.getByName( 'check' ).dependsOn task + } + + private static void configureTestReport( Project project ) + { + project.tasks.create( TaskNames.GLOBAL_TEST_REPORT, TestReport ) { TestReport task -> + task.destinationDir = project.file( "$project.buildDir/reports/tests" ) + task.reportOn project.subprojects.collect { it.tasks.getByName( 'test' ) } + } + def test = project.tasks.getByName( 'test' ) as Test + test.dependsOn project.subprojects.collect { it.tasks.getByName( 'test' ) } + test.dependsOn project.tasks.getByName( TaskNames.GLOBAL_TEST_REPORT ) + test.reports.html.enabled = false + } + + private static void configureJavadocs( Project project ) + { + def releaseSpec = project.extensions.getByType( ReleaseSpecExtension ) + project.tasks.create( TaskNames.JAVADOCS, Javadoc ) { Javadoc task -> + task.group = TaskGroups.DOCUMENTATION + task.description = 'Build the whole SDK public Javadoc' + task.dependsOn ReleaseSpecPlugin.TaskNames.RELEASE_APPROVED_PROJECTS + def options = task.options as StandardJavadocDocletOptions + options.docFilesSubDirs = true + options.encoding = "UTF-8" + options.overview = "${ project.projectDir }/src/javadoc/overview.html" + task.title = "${ PROJECT_TITLE } ${ project.version }" + def apiSources = releaseSpec.approvedProjects.findAll { approved -> + ( approved.name.startsWith( 'org.apache.zest.core' ) && + !approved.name.startsWith( 'org.apache.zest.core.runtime' ) ) || + approved.name.startsWith( 'org.apache.zest.library' ) || + approved.name.startsWith( 'org.apache.zest.extension' ) || + approved.name.startsWith( 'org.apache.zest.tool' ) + } + task.source apiSources.collect { each -> + each.convention.getPlugin( JavaPluginConvention ).sourceSets.getByName( 'main' ).allJava + } + task.destinationDir = project.file( "${ project.convention.getPlugin( JavaPluginConvention ).docsDir }/javadocs" ) + task.classpath = project.files( apiSources.collect { apiProject -> + apiProject.convention.getPlugin( JavaPluginConvention ).sourceSets.getByName( 'main' ).compileClasspath + } ) + options.group( [ + "Core API" : [ "org.apache.zest.api", + "org.apache.zest.api.*", + "org.apache.zest.io", + "org.apache.zest.functional" ], + "Core Bootstrap": [ "org.apache.zest.bootstrap", + "org.apache.zest.bootstrap.*" ], + "Core SPI" : [ "org.apache.zest.spi", + "org.apache.zest.spi.*" ], + "Libraries" : [ "org.apache.zest.library.*" ], + "Extensions" : [ "org.apache.zest.valueserialization.*", + "org.apache.zest.entitystore.*", + "org.apache.zest.index.*", + "org.apache.zest.metrics.*", + "org.apache.zest.cache.*", + "org.apache.zest.migration", + "org.apache.zest.migration.*" ], + "Tools" : [ "org.apache.zest.tools.*", + "org.apache.zest.envisage", + "org.apache.zest.envisage.*" ], + "Test Support" : [ "org.apache.zest.test", + "org.apache.zest.test.*" ] + ] ) + } + project.tasks.create( TaskNames.ARCHIVE_JAVADOCS, Copy ) { Copy task -> + task.dependsOn TaskNames.JAVADOCS + task.from 'build/docs/javadoc/' + if( project.version == '0' || project.version.toString().contains( "SNAPSHOT" ) ) + { + task.into( "$project.projectDir/../zest-web/site/content/java/develop/javadocs/" ) + } + else + { + task.into( "$project.projectDir/../zest-web/site/content/java/$project.version/javadocs/" ) + } + } + } + + private static void configureRat( Project project ) + { + def rat = project.tasks.getByName( 'rat' ) as RatTask + rat.onlyIf { project.version != '0' } + rat.excludes = [ + '**/.DS_Store/**', '**/._*', + // Git Files + '**/.git/**', '**/.gitignore', + // Gradle Files + 'gradle/wrapper/**', '**/gradlew', '**/gradlew.bat', '**/.gradle/**', + // Build Output + '**/build/**', '**/derby.log', 'out/**', + // IDE Files + '**/.idea/**', '**/*.iml', '**/*.ipr', '**/*.iws', + '**/.settings/**', '**/.classpath', '**/.project', + '**/.gradletasknamecache', '**/private/cache/**', + '**/.nb-gradle-properties', '**/.nb-gradle/**', + // JSON files are not allowed to have comments, according to http://www.json.org/ and http://www.ietf.org/rfc/rfc4627.txt + '**/*.json', + // Various Text Resources + '**/README.*', '**/README*.*', '**/TODO', + '**/src/main/resources/**/*.txt', + '**/src/test/resources/**/*.txt', + 'libraries/rest-server/src/main/resources/**/*.htm', + 'libraries/rest-server/src/main/resources/**/*.atom', + 'tools/qidea/src/main/resources/**/*.ft', + 'tools/qidea/src/main/resources/**/*.template', + // Graphic Resources + '**/*.svg', '**/*.gif', '**/*.png', '**/*.jpg', '**/*.psd', + // Keystores + '**/*.jceks', + // Syntax Highlighter - MIT + 'manual/**/sh*.css', 'manual/**/sh*.js', + // jQuery & plugins - MIT + 'manual/**/jquery*.js', + // W3C XML Schemas - W3C Software License + 'samples/rental/src/main/resources/*.xsd', + // Zest Generator Heroes Templates - MIT + 'tools/generator-zest/app/templates/Heroes/**', + // templates that will become the user's source files, should not have license headers + 'tools/shell/src/dist/etc/templates/**', + ] + } + + private static void configureReleaseTask( Project project ) + { + def release = project.tasks.create( 'release' ) + release.description = 'Builds, tests and uploads the release artifacts' + release.group = 'Release' + release.doFirst { + if( System.properties[ 'version' ] == null || System.properties[ 'version' ].toString().contains( 'SNAPSHOT' ) ) + { + throw new GradleException( "'version' must be given as a system property to perform a release." ) + } + } + release.dependsOn 'checkReleaseSpec', + 'rat', + 'archiveJavadocs', + ':org.apache.zest.manual:copyWebsite', + project.allprojects.collect { it.tasks.getByName( 'uploadArchives' ) }, + 'dist' + } +} http://git-wip-us.apache.org/repos/asf/zest-java/blob/56793996/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy index 954291d..07e4e6b 100644 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy +++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy @@ -17,9 +17,11 @@ */ package org.apache.zest.gradle +import groovy.transform.CompileStatic import org.gradle.api.Project import org.gradle.api.artifacts.Dependency +@CompileStatic class ZestExtension { private final Project project http://git-wip-us.apache.org/repos/asf/zest-java/blob/56793996/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestPlugin.groovy deleted file mode 100644 index 2752311..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestPlugin.groovy +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ -package org.apache.zest.gradle - -import groovy.transform.CompileStatic -import org.gradle.api.Plugin -import org.gradle.api.Project - -@CompileStatic -class ZestPlugin implements Plugin<Project> -{ - @Override - void apply( final Project project ) - { - project.extensions.create( "zest", ZestExtension, project ) - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/56793996/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesPlugin.groovy new file mode 100644 index 0000000..6ced34d --- /dev/null +++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesPlugin.groovy @@ -0,0 +1,346 @@ +/* + * 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. + */ +package org.apache.zest.gradle.dependencies + +import groovy.transform.CompileStatic +import org.gradle.api.Action +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.DependencySubstitution +import org.gradle.api.artifacts.component.ModuleComponentSelector +import org.gradle.api.artifacts.repositories.MavenArtifactRepository + +@CompileStatic +class DependenciesPlugin implements Plugin<Project> +{ + static final Map<String, String> REPOSITORIES_URLS = [ + mavenCentral: "https://repo1.maven.org/maven2/", + ops4j : "http://repository.ops4j.org/maven2/", + restlet : 'https://maven.restlet.com/', + clojars : "https://clojars.org/repo/", + ] + + static final def asmVersion = '5.1' + static final def bonecpVersion = '0.8.0.RELEASE' + static final def bouncyVersion = '1.55' + static final def codahaleMetricsVersion = '3.1.2' + static final def commonsDbcpVersion = '2.1.1' + static final def commonsLangVersion = '3.5' + static final def derbyVersion = '10.13.1.1' + static final def dnsJavaVersion = '2.1.7' + static final def ehcacheVersion = '3.1.3' + static final def elasticsearchVersion = '5.0.0' + static final def freemarkerVersion = '2.3.25-incubating' + static final def geodeVersion = '1.0.0-incubating' + static final def groovyVersion = '2.4.7' + static final def h2Version = '1.4.193' + static final def hazelcastVersion = '3.7.2' + static final def hamcrestVersion = '1.3' + static final def httpClientVersion = '4.5.2' + static final def jacksonVersion = '2.8.4' + static final def javascriptVersion = '1.7.7.1' + static final def javasqlgeneratorVersion = '0.3.2' + static final def jcloudsVersion = '1.9.2' + static final def jdbmVersion = '2.4' + static final def jedisVersion = '2.9.0' + static final def jettyVersion = '9.2.17.v20160517' // 9.3.x Tests fail! + static final def jgoodiesLooksVersion = '2.7.0' + static final def jtaVersion = '1.1' + static final def leveldbVersion = '0.9' + static final def leveldbJniVersion = '1.8' + static final def liquibaseVersion = '3.5.3' + static final def logbackVersion = '1.1.7' + static final def mongodbVersion = '3.3.0' + static final def mysqlVersion = '6.0.4' + static final def orgJsonVersion = '20130213' + static final def osgiVersion = '4.2.0' // 4.3.0 Fails to compile! - 5.0.0 exists + static final def pdfboxVersion = '2.0.3' + static final def postgresqlVersion = '9.4.1211' + static final def prefuseVersion = '1.0.1' + static final def restletVersion = '2.3.7' + static final def rdfVersion = '2.7.16' // 2.8.x change query results!! 4.x exists + static final def riakVersion = '2.0.8' + static final def scalaVersion = '2.11.8' + static final def servletVersion = '3.1.0' + static final def shiroVersion = '1.3.2' + static final def skedVersion = '2.1' + static final def slf4jVersion = '1.7.21' + static final def solrVersion = "1.4.1" // 4.x Fails to compile! + static final def springVersion = '4.3.3.RELEASE' + static final def spymemcachedVersion = '2.12.1' + static final def sqliteVersion = '3.14.2.1' + static final def velocityVersion = '1.7' + static final def woodstoxVersion = '4.4.1' + + static final def antVersion = '1.9.7' + static final def awaitilityVersion = '2.0.0' + static final def easyMockVersion = '3.4' + static final def junitVersion = '4.12' + static final def mockitoVersion = '2.2.9' + + static final def libraries = [ + // Ant + ant : "org.apache.ant:ant:$antVersion", + ant_junit : "org.apache.ant:ant-junit:$antVersion", + + // ASM + asm : "org.ow2.asm:asm:$asmVersion", + asm_util : "org.ow2.asm:asm-util:$asmVersion", + asm_commons : "org.ow2.asm:asm-commons:$asmVersion", + + // OSGi + osgi_core : "org.osgi:org.osgi.core:$osgiVersion", + osgi_compendium : "org.osgi:org.osgi.compendium:$osgiVersion", + osgi_enterprise : "org.osgi:org.osgi.enterprise:$osgiVersion", + + // logging + slf4j_api : "org.slf4j:slf4j-api:$slf4jVersion", + slf4j_simple : "org.slf4j:slf4j-simple:$slf4jVersion", + logback : 'ch.qos.logback:logback-classic:' + logbackVersion, + jcl_slf4j : "org.slf4j:jcl-over-slf4j:$slf4jVersion", + jcl_api : 'commons-logging:commons-logging-api:99.0-does-not-exist', //ensure it is never used. + jcl : 'commons-logging:commons-logging:99.0-does-not-exist', // ensure it is never used. + + // org.json + org_json : "org.codeartisans:org.json:$orgJsonVersion", + + // Restlet + restlet : [ "org.restlet.jee:org.restlet:$restletVersion", + "org.restlet.jee:org.restlet.ext.atom:$restletVersion", + "org.restlet.jee:org.restlet.ext.servlet:$restletVersion", + "org.restlet.jee:org.restlet.ext.slf4j:$restletVersion" ], + + // Scala + scala : "org.scala-lang:scala-library:$scalaVersion", + + // Spring + spring_core : [ "org.springframework:spring-beans:$springVersion", + "org.springframework:spring-context:$springVersion" ], + + spring_testsupport : "org.springframework:spring-test:$springVersion", + + // RDF + sesame : [ "org.openrdf.sesame:sesame-model:$rdfVersion", + "org.openrdf.sesame:sesame-queryparser-sparql:$rdfVersion", + "org.openrdf.sesame:sesame-repository-dataset:$rdfVersion", + "org.openrdf.sesame:sesame-repository-http:$rdfVersion", + "org.openrdf.sesame:sesame-rio-api:$rdfVersion", + "org.openrdf.sesame:sesame-rio-n3:$rdfVersion", + "org.openrdf.sesame:sesame-rio-ntriples:$rdfVersion", + "org.openrdf.sesame:sesame-rio-rdfxml:$rdfVersion", + "org.openrdf.sesame:sesame-rio-trig:$rdfVersion", + "org.openrdf.sesame:sesame-rio-trix:$rdfVersion", + "org.openrdf.sesame:sesame-rio-turtle:$rdfVersion", + "org.openrdf.sesame:sesame-sail-api:$rdfVersion", + "org.openrdf.sesame:sesame-sail-memory:$rdfVersion", + "org.openrdf.sesame:sesame-sail-nativerdf:$rdfVersion", + "org.openrdf.sesame:sesame-sail-rdbms:$rdfVersion" ], + sparql : [ "org.openrdf.sesame:sesame-queryresultio-sparqlxml:$rdfVersion", + "org.openrdf.sesame:sesame-queryresultio-sparqljson:$rdfVersion" ], + + // SOLR + solr : [ "org.apache.solr:solr-core:$solrVersion", + "org.apache.solr:solr-solrj:$solrVersion" ], + + // Jetty + jetty_server : "org.eclipse.jetty:jetty-server:$jettyVersion", + jetty_webapp : "org.eclipse.jetty:jetty-webapp:$jettyVersion", + jetty_servlet : "org.eclipse.jetty:jetty-servlet:$jettyVersion", + jetty_http : "org.eclipse.jetty:jetty-http:$jettyVersion", + jetty_io : "org.eclipse.jetty:jetty-io:$jettyVersion", + jetty_jmx : "org.eclipse.jetty:jetty-jmx:$jettyVersion", + jetty_security : "org.eclipse.jetty:jetty-security:$jettyVersion", + jetty_jsp : "org.eclipse.jetty:jetty-jsp:$jettyVersion", + jetty_util : "org.eclipse.jetty:jetty-util:$jettyVersion", + jetty_continuation : "org.eclipse.jetty:jetty-continuation:$jettyVersion", + jetty_client : "org.eclipse.jetty:jetty-client:$jettyVersion", + jetty_xml : "org.eclipse.jetty:jetty-xml:$jettyVersion", + + // Scripting + groovy : "org.codehaus.groovy:groovy-all:$groovyVersion", + + javascript : "org.mozilla:rhino:$javascriptVersion", + + // Library & Extension dependencies + jackson_mapper : "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion", + ehcache : "org.ehcache:ehcache:$ehcacheVersion", + elasticsearch : [ "org.elasticsearch:elasticsearch:$elasticsearchVersion", + "org.elasticsearch.client:transport:$elasticsearchVersion", + // Elasticsearch 5.0 do not work with log4j 2.7 + "org.apache.logging.log4j:log4j-api:2.6.2", + "org.apache.logging.log4j:log4j-core:2.6.2" ], + geode : "org.apache.geode:geode-core:$geodeVersion", + h2 : "com.h2database:h2:$h2Version", + hazelcast : "com.hazelcast:hazelcast:$hazelcastVersion", + jclouds_core : "org.apache.jclouds:jclouds-core:$jcloudsVersion", + jclouds_blobstore : "org.apache.jclouds:jclouds-allblobstore:$jcloudsVersion", + jclouds_filesystem : "org.apache.jclouds.api:filesystem:$jcloudsVersion", + jdbm : "jdbm:jdbm:$jdbmVersion", + jedis : "redis.clients:jedis:$jedisVersion", + jgoodies_looks : "com.jgoodies:jgoodies-looks:$jgoodiesLooksVersion", + leveldb_api : "org.iq80.leveldb:leveldb-api:$leveldbVersion", + leveldb_java : "org.iq80.leveldb:leveldb:$leveldbVersion", + leveldb_jni_all : "org.fusesource.leveldbjni:leveldbjni-all:$leveldbJniVersion", + mongodb : "org.mongodb:mongo-java-driver:$mongodbVersion", + riak : "com.basho.riak:riak-client:$riakVersion", + jta : "javax.transaction:jta:$jtaVersion", + javaSqlGenerator : "org.java-sql-generator:org.java-sql-generator.api:$javasqlgeneratorVersion", + javaSqlGeneratorImpl: "org.java-sql-generator:org.java-sql-generator.implementation:$javasqlgeneratorVersion", + velocity : "org.apache.velocity:velocity:$velocityVersion", + commons_dbcp : "org.apache.commons:commons-dbcp2:$commonsDbcpVersion", + commons_lang : "org.apache.commons:commons-lang3:$commonsLangVersion", + servlet_api : "javax.servlet:javax.servlet-api:$servletVersion", + http_client : "org.apache.httpcomponents:httpclient:$httpClientVersion", + woodstox : "org.codehaus.woodstox:woodstox-core-asl:$woodstoxVersion", + restlet_xml : "org.restlet.jee:org.restlet.ext.xml:$restletVersion", + bouncy_castle : "org.bouncycastle:bcprov-jdk15on:$bouncyVersion", + dnsjava : "dnsjava:dnsjava:$dnsJavaVersion", + freemarker : "org.freemarker:freemarker:$freemarkerVersion", + shiro : "org.apache.shiro:shiro-core:$shiroVersion", + shiro_web : "org.apache.shiro:shiro-web:$shiroVersion", + bonecp : "com.jolbox:bonecp:$bonecpVersion", + liquibase : "org.liquibase:liquibase-core:$liquibaseVersion", + sked : "org.codeartisans:sked:$skedVersion", + pdfbox : "org.apache.pdfbox:pdfbox:$pdfboxVersion", + prefuse : "de.sciss:prefuse-core:$prefuseVersion", + spymemcached : "net.spy:spymemcached:$spymemcachedVersion", + codahale_metrics : [ "io.dropwizard.metrics:metrics-core:$codahaleMetricsVersion", + "io.dropwizard.metrics:metrics-healthchecks:$codahaleMetricsVersion" ], + + // Testing + junit : "junit:junit:$junitVersion", + hamcrest : [ "org.hamcrest:hamcrest-core:$hamcrestVersion", + "org.hamcrest:hamcrest-library:$hamcrestVersion" ], + awaitility : "org.awaitility:awaitility:$awaitilityVersion", + easymock : "org.easymock:easymock:$easyMockVersion", + mockito : "org.mockito:mockito-core:$mockitoVersion", + + // Tests dependencies + derby : "org.apache.derby:derby:$derbyVersion", + derbyclient : "org.apache.derby:derbyclient:$derbyVersion", + derbynet : "org.apache.derby:derbynet:$derbyVersion", + postgres : "org.postgresql:postgresql:$postgresqlVersion", + mysql_connector : "mysql:mysql-connector-java:$mysqlVersion", + sqlite : "org.xerial:sqlite-jdbc:$sqliteVersion", + ] + + static final Map<String, Object> defaultTestDependencies = [ + testCompile: [ libraries[ 'junit' ], libraries[ 'hamcrest' ], libraries[ 'ant' ], libraries[ 'ant_junit' ] ], + testRuntime: [ libraries[ 'asm' ], libraries[ 'asm_commons' ], libraries[ 'asm_util' ] ] + ] as Map + + @Override + void apply( final Project project ) + { + applyRepositories( project ) + applyLibraries( project ) + applyDependencyResolutionRules( project ) + applyDefaultTestDependencies( project ) + } + + private static void applyRepositories( Project project ) + { + REPOSITORIES_URLS.each { name, url -> + project.repositories.maven { MavenArtifactRepository repo -> + repo.name = name + repo.url = url + } + } + } + + private static void applyLibraries( Project project ) + { + if( project.rootProject == project ) + { + project.extensions.extraProperties.set( 'libraries', libraries ) + } + } + + private static void applyDependencyResolutionRules( Project project ) + { + project.configurations.all( + { Configuration configuration -> + configuration.resolutionStrategy.dependencySubstitution.all( { DependencySubstitution dep -> + if( dep.requested instanceof ModuleComponentSelector ) + { + def requested = dep.requested as ModuleComponentSelector + // Always resolve SLF4J to the same version + if( requested.group == 'org.slf4j' ) + { + dep.useTarget group: requested.group, name: requested.module, version: slf4jVersion + } + // Always resolve ASM to the same version + if( requested.group == 'org.ow2.asm' ) + { + dep.useTarget group: requested.group, name: requested.module, version: asmVersion + } + // Always resolve OSGi to the same version + if( requested.group == 'org.osgi' ) + { + dep.useTarget group: requested.group, name: requested.module, version: osgiVersion + } + // Always resolve Jackson to the same version + if( requested.group.startsWith( 'com.fasterxml.jackson' ) && requested.module != 'jackson-parent' ) + { + dep.useTarget group: requested.group, name: requested.module, version: jacksonVersion + } + // woodstox:wstx-asl is broken (no pom), use org.codehaus.woodstox:wstx-asl instead + if( requested.group == 'woodstox' && requested.module == 'wstx-asl' ) + { + dep.useTarget group: 'org.codehaus.woodstox', name: 'wstx-asl', version: requested.version + } + // some bad citizens have SNAPSHOT parents ... + if( requested.module == 'commons-sandbox-parent' && requested.version == '3-SNAPSHOT' ) + { + dep.useTarget group: requested.group, name: requested.module, version: '3' + } + // GSON 2.3 POM is invalid, use 2.3.1 instead .. see https://github.com/google/gson/issues/588 + if( requested.group == 'com.google.code.gson' && requested.module == 'gson' && requested.version == '2.3' ) + { + dep.useTarget group: requested.group, name: requested.module, version: '2.3.1' + } + // Findbugs Annotation is LGPL, use https://github.com/stephenc/findbugs-annotations which is + // Apache 2 licensed instead + if( requested.group == 'net.sourceforge.findbugs' && requested.module == 'annotations' ) + { + dep.useTarget group: 'com.github.stephenc.findbugs', name: 'findbugs-annotations', version: '1.3.9-1' + } + } + } as Action<DependencySubstitution> ) + } as Action<Configuration> ) + } + + private static void applyDefaultTestDependencies( Project project ) + { + defaultTestDependencies.each { String configuration, Object dependencies -> + dependencies.each { dependency -> + if( dependency instanceof Collection ) + { + dependency.each { subdep -> + project.dependencies.add( configuration, subdep ) + } + } + else + { + project.dependencies.add( configuration, dependency ) + } + } + } + } +}
