http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/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 deleted file mode 100644 index c2f9bfe..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy +++ /dev/null @@ -1,79 +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.Project -import org.gradle.api.artifacts.Dependency - -@CompileStatic -class PolygeneExtension -{ - private final Project project - final Core core - - PolygeneExtension( Project project ) - { - this.project = project - this.core = new Core() - } - - boolean isDevelopmentVersion() - { - return project.version == '0' || project.version.toString().contains( 'SNAPSHOT' ) - } - - boolean isReleaseVersion() - { - return !isDevelopmentVersion() - } - - class Core - { - Dependency api = core( 'api' ) - Dependency spi = core( 'spi' ) - Dependency runtime = core( 'runtime' ) - Dependency bootstrap = core( 'bootstrap' ) - Dependency testsupport = core( 'testsupport' ) - } - - private Dependency core( String name ) - { - return dependency( 'org.apache.zest.core', "org.apache.zest.core.$name" ) - } - - Dependency library( String name ) - { - return dependency( 'org.apache.zest.libraries', "org.apache.zest.library.$name" ) - } - - Dependency extension( String name ) - { - return dependency( 'org.apache.zest.extensions', "org.apache.zest.extension.$name" ) - } - - Dependency tool( String name ) - { - return dependency( 'org.apache.zest.tools', "org.apache.zest.tool.$name" ) - } - - private Dependency dependency( String group, String name ) - { - project.dependencies.project( path: ":$group:$name" ) - } -}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesDeclarationExtension.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesDeclarationExtension.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesDeclarationExtension.groovy deleted file mode 100644 index 8a5570c..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesDeclarationExtension.groovy +++ /dev/null @@ -1,33 +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.dependencies - -import groovy.transform.CompileStatic -import org.gradle.api.artifacts.DependencySubstitution -import org.gradle.api.artifacts.component.ModuleComponentSelector -import org.gradle.internal.BiAction - -@CompileStatic -class DependenciesDeclarationExtension -{ - final Map<String, String> repositoriesUrls = [ : ] - final Map<String, Object> libraries = [ : ] - final Map<String, List<Object>> defaultDependencies = [ : ] - BiAction<DependencySubstitution, ModuleComponentSelector> dependencySubstitutionSpec - final Map<String, String> buildToolsVersions = [ : ] -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesDeclarationPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesDeclarationPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesDeclarationPlugin.groovy deleted file mode 100644 index c04ca55..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesDeclarationPlugin.groovy +++ /dev/null @@ -1,30 +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.dependencies - -import org.gradle.api.Plugin -import org.gradle.api.Project - -class DependenciesDeclarationPlugin implements Plugin<Project> -{ - @Override - void apply( Project project ) - { - project.extensions.create( 'dependenciesDeclaration', DependenciesDeclarationExtension ) - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/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 deleted file mode 100644 index bd9efde..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/dependencies/DependenciesPlugin.groovy +++ /dev/null @@ -1,89 +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.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> -{ - @Override - void apply( final Project project ) - { - def dependenciesDeclaration = project.rootProject.extensions.getByType( DependenciesDeclarationExtension ) - applyRepositories( project, dependenciesDeclaration ) - applyLibraries( project, dependenciesDeclaration ) - applyDependencyResolutionRules( project, dependenciesDeclaration ) - applyDefaultDependencies( project, dependenciesDeclaration ) - } - - private static void applyRepositories( Project project, DependenciesDeclarationExtension declaration ) - { - declaration.repositoriesUrls.each { name, url -> - project.repositories.maven { MavenArtifactRepository repo -> - repo.name = name - repo.url = url - } - } - } - - private static void applyLibraries( Project project, DependenciesDeclarationExtension declaration ) - { - project.extensions.extraProperties.set 'libraries', declaration.libraries - } - - private static void applyDependencyResolutionRules( Project project, DependenciesDeclarationExtension declaration ) - { - project.configurations.all( - { Configuration configuration -> - configuration.resolutionStrategy.dependencySubstitution.all( - { DependencySubstitution dep -> - if( dep.requested instanceof ModuleComponentSelector ) - { - def selector = dep.requested as ModuleComponentSelector - declaration.dependencySubstitutionSpec.execute dep, selector - } - } as Action<DependencySubstitution> ) - } as Action<Configuration> ) - } - - private static void applyDefaultDependencies( Project project, DependenciesDeclarationExtension declaration ) - { - declaration.defaultDependencies.each { String configuration, List<Object> dependencies -> - dependencies.each { dependency -> - if( dependency instanceof Collection ) - { - dependency.each { subdep -> - project.dependencies.add( configuration, subdep ) - } - } - else - { - project.dependencies.add( configuration, dependency ) - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/dist/DistributionPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/dist/DistributionPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/dist/DistributionPlugin.groovy deleted file mode 100644 index 6d45427..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/dist/DistributionPlugin.groovy +++ /dev/null @@ -1,387 +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.dist - -import groovy.transform.CompileStatic -import groovy.transform.TypeCheckingMode -import org.apache.rat.gradle.RatTask -import org.apache.tools.ant.filters.ReplaceTokens -import org.apache.zest.gradle.RootProjectPlugin -import org.apache.zest.gradle.TaskGroups -import org.apache.zest.gradle.dependencies.DependenciesDeclarationExtension -import org.apache.zest.gradle.release.ReleaseSpecExtension -import org.apache.zest.gradle.release.ReleaseSpecPlugin -import org.gradle.api.Action -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.file.CopySpec -import org.gradle.api.file.FileCopyDetails -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.GradleBuild -import org.gradle.api.tasks.bundling.Compression -import org.gradle.api.tasks.bundling.Tar -import org.gradle.api.tasks.bundling.Zip - -@CompileStatic -class DistributionPlugin implements Plugin<Project> -{ - static class TaskNames - { - static final String UNPACK_SOURCE_DIST = 'unpackSrcDist' - static final String UNPACK_BINARY_DIST = 'unpackBinDist' - static final String CHECK_SOURCE_DIST = 'checkSrcDist' - static final String CHECK_BINARY_DIST = 'checkBinDist' - static final String CHECK_BINARY_DIST_RAT = 'checkBinDist_rat' - static final String GENERATE_MAVEN_OFFLINE_HELPERS = 'generateMavenGoOfflineHelpers' - static final String GENERATE_GRADLE_OFFLINE_HELPERS = 'generateGradleGoOfflineHelpers' - static final String CHECK_MAVEN_OFFLINE_HELPERS = 'checkMavenGoOfflineHelpers' - static final String CHECK_GRADLE_OFFLINE_HELPERS = 'checkGradleGoOfflineHelpers' - } - - @Override - void apply( final Project project ) - { - configureSourceDistribution( project ) - configureBinaryDistribution( project ) - configureDistributionChecksums( project ) - configureHelperTasks( project ) - } - - private static void configureSourceDistribution( Project project ) - { - def releaseSpec = project.extensions.getByType( ReleaseSpecExtension ) - def srcDistFilesCopySpec = project.copySpec { CopySpec spec -> - spec.from '.' - spec.include '*.txt' - spec.include 'doap.rdf' - spec.include '*.gradle' - spec.include 'gradlew*' - spec.include 'gradle/**' - spec.include 'etc/**' - spec.include 'buildSrc/**' - spec.include 'src/**' - releaseSpec.approvedProjects.each { p -> - def relPath = new File( project.projectDir.toURI().relativize( p.projectDir.toURI() ).toString() ) - spec.include "$relPath/**" - } - spec.include 'manual/**' - spec.include 'samples/**' - spec.include 'tests/**' - spec.include 'tutorials/**' - spec.include 'tools/shell/**' - // Filtered, see below - spec.exclude 'settings.gradle' - spec.exclude 'gradle.properties' - // Excludes - spec.exclude '**/build/**' // Build output - spec.exclude 'derby.log' // Derby test garbage - spec.exclude '**/*.iml' // IDEA files - spec.exclude '**/*.ipr' // IDEA files - spec.exclude '**/*.iws' // IDEA files - spec.exclude '**/.idea' // IDEA files - spec.exclude '**/out/**' // IDEA build output - spec.exclude '**/.classpath' // Eclipse files - spec.exclude '**/.project' // Eclipse files - spec.exclude '**/.settings' // Eclipse files - spec.exclude '**/.nb-gradle/**' // Netbeans files - spec.exclude '**/.nb-gradle*' // Netbeans files - spec.exclude '**/.git/**' // Git directories - spec.exclude '**/.git*' // Git files - spec.exclude '**/.gradle/**' // Gradle management files - spec.exclude '**/.gradletasknamecache' // Gradle cache - spec.into '.' - } - def srcDistFilteredFilesTask = project.tasks.create( 'srcDistFilteredFiles' ) - srcDistFilteredFilesTask.description = 'Apply release specification to source distribution build scripts' - // Generates various files for the source distribution - // - settings.gradle - // - gradle.properties to set version ! - def filteredDir = new File( "$project.buildDir/tmp/srcDistFilteredFiles" ) - srcDistFilteredFilesTask.outputs.file filteredDir - srcDistFilteredFilesTask.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 - releaseSpec.approvedProjects.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=$project.version\n" - } - def srcDistFilteredFilesCopySpec = project.copySpec { CopySpec spec -> - spec.from srcDistFilteredFilesTask - spec.into '.' - } - def srcDistCopySpec = project.copySpec { CopySpec spec -> - spec.into "apache-zest-java-$project.version-src" - spec.with srcDistFilesCopySpec - spec.with srcDistFilteredFilesCopySpec - } - - def zipSources = project.tasks.create( 'zipSources', Zip ) { Zip task -> - task.group = TaskGroups.DISTRIBUTION - task.description = 'Assemble .zip source distribution' - task.baseName = 'apache-zest-java' - task.with srcDistCopySpec - task.classifier = 'src' - } - def tarSources = project.tasks.create( 'tarSources', Tar ) { Tar task -> - task.group = TaskGroups.DISTRIBUTION - task.description = 'Assemble .tar.gz source distribution' - task.baseName = 'apache-zest-java' - task.with srcDistCopySpec - task.compression = Compression.GZIP - task.classifier = 'src' - } - project.artifacts.add( 'archives', zipSources ) - project.artifacts.add( 'archives', tarSources ) - - project.tasks.create( TaskNames.UNPACK_SOURCE_DIST, Copy ) { Copy task -> - task.group = TaskGroups.DISTRIBUTION - task.description = "Unpack source distribution" - task.with srcDistCopySpec - task.into 'build/unpacked-distributions/src' - } - - def unpackedSrcDistDir = project.file( "build/unpacked-distributions/src/apache-zest-java-$project.version-src" ) - project.tasks.create( TaskNames.CHECK_SOURCE_DIST, GradleBuild.class, { GradleBuild task -> - task.group = TaskGroups.DISTRIBUTION_VERIFICATION - task.description = "Check the source distribution by running the 'check' and 'assemble' tasks inside" - task.dependsOn TaskNames.UNPACK_SOURCE_DIST - task.buildFile = "$unpackedSrcDistDir/build.gradle" - task.tasks = [ 'check', 'assemble' ] - } as Action<GradleBuild> ) - } - - private static void configureBinaryDistribution( Project project ) - { - configureGoOfflineHelpers( project ) - - def releaseSpec = project.extensions.getByType( ReleaseSpecExtension ) - def reportsDistCopySpec = project.copySpec { CopySpec spec -> - spec.from "$project.buildDir/reports" - spec.into 'docs/reports' - } - def docsCopySpec = project.copySpec { CopySpec spec -> - spec.from 'build/docs' - spec.from 'manual/build/docs/website' - spec.into 'docs' - } - def runtimeDependenciesListCopySpec = project.copySpec { CopySpec spec -> - releaseSpec.approvedProjects.collect { p -> - spec.into( 'libs/' ) { CopySpec sub -> - sub.from "$p.buildDir/reports/project/dependencies.txt" - sub.rename 'dependencies.txt', "${ p.name }-${ p.version }-runtime-deps.txt" - } - } - spec.into( '.' ) { CopySpec sub -> - sub.from project.tasks.getByName( TaskNames.GENERATE_MAVEN_OFFLINE_HELPERS ).outputs - sub.from project.tasks.getByName( TaskNames.GENERATE_GRADLE_OFFLINE_HELPERS ).outputs - } - } - def libsCopySpec = project.copySpec { CopySpec spec -> - releaseSpec.approvedProjects.collect { proj -> - spec.into( 'libs/' ) { CopySpec sub -> - sub.from proj.configurations.getByName( 'archives' ).artifacts.files - sub.exclude '**-testsources.jar' - sub.exclude '**/*.asc' - } - } - } - def extraDistTextCopySpec = project.copySpec { CopySpec spec -> - releaseSpec.approvedProjects.collect { p -> - spec.from project.fileTree( dir: "$p.projectDir/src/dist/", include: '**', exclude: "**/*.jar*" ) - spec.eachFile { FileCopyDetails fcd -> - fcd.filter( ReplaceTokens, tokens: [ version: project.version ] ) - } - } - spec.into '.' - } - def extraDistBinCopySpec = project.copySpec { CopySpec spec -> - releaseSpec.approvedProjects.collect { p -> - spec.from "$p.projectDir/src/dist/" - spec.include '**/*.jar' - spec.include '**/*.jar_' - } - spec.into '.' - } - def binDistNoticesCopySpec = project.copySpec { CopySpec spec -> - spec.from "$project.projectDir/LICENSE.txt" - spec.from "$project.projectDir/src/bin-dist" - spec.into '.' - } - def binDistImage = project.copySpec { CopySpec spec -> - spec.into "apache-zest-java-$project.version-bin" - spec.with binDistNoticesCopySpec - spec.with docsCopySpec - spec.with reportsDistCopySpec - spec.with runtimeDependenciesListCopySpec - spec.with extraDistTextCopySpec - spec.with extraDistBinCopySpec - spec.with libsCopySpec - } - - def zipBinaries = project.tasks.create( 'zipBinaries', Zip ) { Zip task -> - task.group = TaskGroups.DISTRIBUTION - task.description = 'Assemble .zip binary distribution' - task.dependsOn project.tasks.getByName( RootProjectPlugin.TaskNames.BUILD_ALL ) - task.baseName = 'apache-zest-java' - task.classifier = 'bin' - task.with binDistImage - } - def tarBinaries = project.tasks.create( 'tarBinaries', Tar ) { Tar task -> - task.group = TaskGroups.DISTRIBUTION - task.description = 'Assemble .tar.gz binary distribution' - task.dependsOn project.tasks.getByName( RootProjectPlugin.TaskNames.BUILD_ALL ) - task.baseName = 'apache-zest-java' - task.classifier = 'bin' - task.compression = Compression.GZIP - task.with binDistImage - } - project.artifacts.add( 'archives', zipBinaries ) - project.artifacts.add( 'archives', tarBinaries ) - - project.tasks.create( TaskNames.UNPACK_BINARY_DIST, Copy ) { Copy task -> - task.group = TaskGroups.DISTRIBUTION - task.description = "Unpack binary distribution" - task.with binDistImage - task.into 'build/unpacked-distributions/bin' - } - - configureBinaryDistributionCheck( project ) - } - - private static void configureGoOfflineHelpers( Project project ) - { - def externalRepos = project.rootProject.extensions.getByType( DependenciesDeclarationExtension ).repositoriesUrls - def approvedProjectsTask = project.tasks.getByName( ReleaseSpecPlugin.TaskNames.RELEASE_APPROVED_PROJECTS ) - def genOfflineMaven = project.tasks.create( TaskNames.GENERATE_MAVEN_OFFLINE_HELPERS, - GoOfflineHelpersTasks.GenerateMaven ) - def genOfflineGradle = project.tasks.create( TaskNames.GENERATE_GRADLE_OFFLINE_HELPERS, - GoOfflineHelpersTasks.GenerateGradle ) - genOfflineMaven.repositories = externalRepos - genOfflineGradle.repositories = externalRepos - [ genOfflineMaven, genOfflineGradle ].each { task -> - task.group = TaskGroups.DISTRIBUTION - task.dependsOn approvedProjectsTask - } - def checkOfflineMaven = project.tasks.create( TaskNames.CHECK_MAVEN_OFFLINE_HELPERS, - GoOfflineHelpersTasks.CheckMaven ) - checkOfflineMaven.group = TaskGroups.DISTRIBUTION_VERIFICATION - checkOfflineMaven.description = 'Check binary distribution Maven dependencies download helper' - checkOfflineMaven.dependsOn genOfflineMaven - def checkOfflineGradle = project.tasks.create( TaskNames.CHECK_GRADLE_OFFLINE_HELPERS, - GoOfflineHelpersTasks.CheckGradle ) - checkOfflineGradle.group = TaskGroups.DISTRIBUTION_VERIFICATION - checkOfflineGradle.description = 'Check binary distribution Gradle dependencies download helper' - checkOfflineGradle.dependsOn genOfflineGradle - [ checkOfflineMaven, checkOfflineGradle ].each { task -> - task.group = TaskGroups.DISTRIBUTION_VERIFICATION - task.dependsOn TaskNames.UNPACK_BINARY_DIST - } - } - - private static void configureBinaryDistributionCheck( Project project ) - { - def unpackedBinDistDir = project.file( "build/unpacked-distributions/bin/apache-zest-java-$project.version-bin" ) - project.tasks.create( TaskNames.CHECK_BINARY_DIST_RAT, RatTask, { RatTask task -> - task.group = TaskGroups.DISTRIBUTION_VERIFICATION - task.description = "Checks binary distribution using Apache RAT" - task.dependsOn TaskNames.UNPACK_BINARY_DIST - task.inputDir = unpackedBinDistDir.absolutePath - task.reportDir = project.file( 'build/reports/rat-bin-dist' ) - task.excludes = [ - '.gradle/**', - 'docs/reports/**', - 'docs/javadocs/**', - 'etc/templates/**', - 'libs/**' - ] - } as Action<RatTask> ) - project.tasks.getByName( TaskNames.CHECK_MAVEN_OFFLINE_HELPERS ) { GoOfflineHelpersTasks.CheckMaven task -> - task.directory = unpackedBinDistDir - } - project.tasks.getByName( TaskNames.CHECK_GRADLE_OFFLINE_HELPERS ) { GoOfflineHelpersTasks.CheckGradle task -> - task.directory = unpackedBinDistDir - task.mustRunAfter TaskNames.CHECK_MAVEN_OFFLINE_HELPERS - } - project.tasks.create( TaskNames.CHECK_BINARY_DIST ) { Task task -> - task.group = TaskGroups.DISTRIBUTION_VERIFICATION - task.description = 'Checks binary distribution' - task.dependsOn TaskNames.CHECK_BINARY_DIST_RAT - task.dependsOn TaskNames.CHECK_MAVEN_OFFLINE_HELPERS - task.dependsOn TaskNames.CHECK_GRADLE_OFFLINE_HELPERS - } - } - - @CompileStatic( TypeCheckingMode.SKIP ) - private static void configureDistributionChecksums( Project project ) - { - project.tasks.withType( Zip ) { Zip task -> - task.doLast { - project.ant.checksum file: task.archivePath, algorithm: 'MD5' - project.ant.checksum file: task.archivePath, algorithm: 'SHA-512' - } - } - project.tasks.withType( Tar ) { Tar task -> - task.doLast { - project.ant.checksum file: task.archivePath, algorithm: 'MD5' - project.ant.checksum file: task.archivePath, algorithm: 'SHA-512' - } - } - } - - private static void configureHelperTasks( Project project ) - { - project.tasks.create( 'dist', Copy ) { Copy task -> - task.group = TaskGroups.DISTRIBUTION - task.description = "Assembles source and binary distributions" - task.dependsOn 'install' - task.from project.tasks.getByName( 'unpackBinDist' ) - task.into "$project.buildDir/dist" - } - project.tasks.create( 'checkDists' ) { Task task -> - task.group = TaskGroups.DISTRIBUTION_VERIFICATION - task.description = "Checks source and binary distributions" - task.dependsOn TaskNames.CHECK_SOURCE_DIST, TaskNames.CHECK_BINARY_DIST - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/dist/GoOfflineHelpersTasks.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/dist/GoOfflineHelpersTasks.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/dist/GoOfflineHelpersTasks.groovy deleted file mode 100644 index 8ff7540..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/dist/GoOfflineHelpersTasks.groovy +++ /dev/null @@ -1,345 +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.dist - -import groovy.transform.CompileStatic -import org.apache.zest.gradle.release.ReleaseSpecExtension -import org.apache.zest.gradle.tasks.ExecLogged -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.Project -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.artifacts.result.ResolvedComponentResult -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction -import org.gradle.process.ExecSpec - -/** - * Tasks to generate and check go-offline maven and gradle helpers bundled with the binary distribution. - */ -@CompileStatic -interface GoOfflineHelpersTasks -{ - class GenerateMaven extends DefaultTask - { - static final String POM_FILENAME = 'go-offline.pom' - - @Input - Map<String, String> repositories = [ : ] - - @Internal - File outputDir = new File( project.buildDir, 'go-offline-helpers' ) - - @OutputFile - File getMavenGoOfflineHelper() - { - return new File( outputDir, POM_FILENAME ) - } - - GenerateMaven() - { - super(); - outputs.upToDateWhen { false } - } - - @TaskAction - void generate() - { - outputDir.mkdirs() - def components = Utils.resolveAllRuntimeComponents( project ) - def maven = generateMaven( components ) - mavenGoOfflineHelper.text = maven - } - - private String generateMaven( Set<ResolvedComponentResult> components ) - { - def pom = Utils.licenseHeader( project.file( 'etc/header.txt' ).text, 'xml' ) - pom += '<project>\n <modelVersion>4.0.0</modelVersion>\n' - pom += - " <groupId>org.apache.zest</groupId>\n <artifactId>go-offline-helper</artifactId>\n <version>$project.version</version>\n" - pom += ' <packaging>pom</packaging>\n' - pom += - ' <!--\n This pom has the sole purpose of downloading all dependencies in a directory relative to this file named \'dependencies\'.\n' - pom += " Use the following command:\n\n mvn -f $POM_FILENAME validate\n -->\n <repositories>\n" - repositories.entrySet().each { repo -> - pom += " <repository><id>go-offline-repo-$repo.key</id><url>${ repo.value }</url></repository>\n" - } - pom += ' </repositories>\n <dependencies>\n' - components.each { comp -> - pom += ' <dependency>\n' - pom += " <groupId>$comp.moduleVersion.group</groupId>\n" - pom += " <artifactId>$comp.moduleVersion.name</artifactId>\n" - pom += " <version>$comp.moduleVersion.version</version>\n" - pom += ' </dependency>\n' - } - pom += """ </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> -""" - return pom - } - } - - class GenerateGradle extends DefaultTask - { - static final String BUILD_SCRIPT_FILENAME = 'go-offline.gradle' - - @Input - Map<String, String> repositories = [ : ] - - @Internal - File outputDir = new File( project.buildDir, 'go-offline-helpers' ) - - @OutputFile - File getGradleGoOfflineHelper() - { - return new File( outputDir, BUILD_SCRIPT_FILENAME ) - } - - GenerateGradle() - { - super(); - outputs.upToDateWhen { false } - } - - @TaskAction - void generate() - { - outputDir.mkdirs() - def components = Utils.resolveAllRuntimeComponents( project ) - def gradle = generateGradle( components ) - gradleGoOfflineHelper.text = gradle - } - - private String generateGradle( Set<ResolvedComponentResult> components ) - { - def build = Utils.licenseHeader( project.file( 'etc/header.txt' ).text, 'java' ) - build += '// This gradle build file has the sole purpose of downloading all dependencies in a directory\n' - build += '// relative to this file named \'dependencies\'.\n' - build += "// Use the following command: gradle -b $BUILD_SCRIPT_FILENAME download\n" - build += 'apply plugin: \'java\'\nconfigurations { download }\nrepositories {\n' - repositories.entrySet().each { repo -> - build += " maven { url '${ repo.value }' }\n" - } - build += '}\ndependencies {\n' - components.each { comp -> - def depCoords = "${ comp.moduleVersion.group }:${ comp.moduleVersion.name }:${ comp.moduleVersion.version }" - build += " download( '$depCoords' ) { transitive = false }\n" - } - build += """} -task download( type: Copy ) { - outputs.upToDateWhen { false } - 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/' ) -} -""" - return build - } - } - - class CheckMaven extends DefaultTask - { - @Internal - File directory - - @InputFile - File getMavenGoOfflineHelper() - { - return new File( directory, GenerateMaven.POM_FILENAME ) - } - - CheckMaven() - { - super(); - description = 'Check the binary distribution Maven go-offline helper' - outputs.upToDateWhen { false } - onlyIf { Utils.isMvnInstalled() } - } - - @TaskAction - void check() - { - def dependenciesDir = new File( directory, 'dependencies' ) - project.delete dependenciesDir - def outLog = project.file( "$project.buildDir/tmp/$name/stdout.log" ) - def errLog = project.file( "$project.buildDir/tmp/$name/stderr.log" ) - def command = [ 'mvn', '-e', '-f', GenerateMaven.POM_FILENAME, 'validate' ] as Object[] - ExecLogged.execLogged( project, outLog, errLog ) { ExecSpec spec -> - spec.workingDir directory - spec.commandLine command - } - Utils.checkAllJarsArePresent( project, dependenciesDir, GenerateMaven.POM_FILENAME ) - } - } - - class CheckGradle extends DefaultTask - { - @Internal - File directory - - @InputFile - File getGradleGoOfflineHelper() - { - return new File( directory, GenerateGradle.BUILD_SCRIPT_FILENAME ) - } - - CheckGradle() - { - super(); - description = 'Check the binary distribution Gradle go-offline helper' - outputs.upToDateWhen { false } - } - - @TaskAction - void check() - { - def buildScript = new File( directory, GenerateGradle.BUILD_SCRIPT_FILENAME ) - def dependenciesDir = new File( directory, 'dependencies' ) - project.delete dependenciesDir - def outLog = project.file( "$project.buildDir/tmp/$name/stdout.log" ) - def errLog = project.file( "$project.buildDir/tmp/$name/stderr.log" ) - ExecLogged.execLogged( project, outLog, errLog ) { ExecSpec spec -> - spec.workingDir project.projectDir - spec.commandLine './gradlew', '-u', '-s', '-b', buildScript.absolutePath, 'download' - } - Utils.checkAllJarsArePresent( project, dependenciesDir, GenerateGradle.BUILD_SCRIPT_FILENAME ) - } - } - - static class Utils - { - // Do the global dependency resolution here so there won't be any surprise 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 - private static Set<ResolvedComponentResult> resolveAllRuntimeComponents( Project rootProject ) - { - def allRuntimeDeps = getAllRuntimeDependencies( rootProject ) - def configuration = rootProject.configurations.findByName( 'goOfflineHelpers' ) - if( !configuration ) - { - configuration = rootProject.configurations.create( 'goOfflineHelpers' ) - allRuntimeDeps.each { set -> rootProject.dependencies.add( configuration.name, set ) } - } - return configuration.incoming.resolutionResult.allComponents.findAll { ResolvedComponentResult comp -> - !comp.moduleVersion.group.startsWith( 'org.apache.zest' ) - } as Set<ResolvedComponentResult> - } - - private static List<Dependency> getAllRuntimeDependencies( Project rootProject ) - { - def releaseSpec = rootProject.extensions.getByType( ReleaseSpecExtension ) - def allDependencies = releaseSpec.approvedProjects.collect { project -> - project.configurations.getByName( 'runtime' ).allDependencies - }.flatten() as List<Dependency> - return allDependencies.findAll { Dependency dep -> - !( dep instanceof ProjectDependency ) && dep.name != null && !dep.group.startsWith( 'org.apache.zest' ) - } - } - - private static void checkAllJarsArePresent( Project rootProject, File dependenciesDir, String helper ) - { - def allDependencies = getAllRuntimeDependencies( rootProject ) - allDependencies.each { Dependency dep -> - def jarName = "${ dep.name }-${ dep.version }.jar" - def jarFile = new File( dependenciesDir, jarName ) - if( !jarFile.exists() ) - { - throw new GradleException( "Binary distribution $helper failed!\n" + - "\tMissing: $dep\n" + - "\tin $jarFile" ); - } - } - } - - private static boolean isMvnInstalled() - { - def pathDirs = System.getenv( 'PATH' ).split( File.pathSeparator ) - def flattened = pathDirs.collect( { String pathDir -> new File( pathDir, 'mvn' ) } ).flatten() as List<File> - return flattened.find( { File pathDir -> pathDir.isFile() } ) != null - } - - // Generate license headers with comment styles - private static String licenseHeader( String base, String flavour ) - { - def header - switch( flavour ) - { - case 'java': case 'groovy': 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 - } - - private static String licenseHeader_wrap( String base, String top, String left, String bottom ) - { - ( top ? "$top\n" : '' ) + base.readLines().collect { "${ left }${ it }" }.join( '\n' ) + '\n' + - ( bottom ? "$bottom\n" : '' ) - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/AsciidocBuildInfoPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/AsciidocBuildInfoPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/AsciidocBuildInfoPlugin.groovy deleted file mode 100644 index 324c196..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/AsciidocBuildInfoPlugin.groovy +++ /dev/null @@ -1,60 +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.doc - -import groovy.transform.CompileStatic -import org.apache.zest.gradle.TaskGroups -import org.gradle.api.Project -import org.gradle.api.Plugin - -@CompileStatic -class AsciidocBuildInfoPlugin implements Plugin<Project> -{ - final static String TASK_NAME = 'makeAsciidocBuildInfo' - - def void apply( Project project ) - { - def buildInfoDir = new File( project.buildDir, "docs/buildinfo" ); - - def makeAsciidocBuildInfoTask = project.tasks.create( TASK_NAME ) - makeAsciidocBuildInfoTask.group = TaskGroups.DOCUMENTATION - makeAsciidocBuildInfoTask.description = 'Generates asciidoc artifact snippet' - makeAsciidocBuildInfoTask.doLast { - buildInfoDir.mkdirs() - - // GroupID, ArtifactID, Version table in artifact.txt - def artifactTableFile = new File( buildInfoDir, "artifact.txt" ) - def artifactTable = """ - |.Artifact - |[role="artifact", options="header,autowidth"] - ||=================================================== - ||Group ID|Artifact ID|Version - ||${ project.group }|${ project.name }|${ project.version } - ||=================================================== - """.stripMargin() - artifactTableFile.withWriter { out -> out.println( artifactTable ) } - } - - // Declare inputs/outputs - if( project.getBuildFile() != null && project.getBuildFile().exists() ) - { - makeAsciidocBuildInfoTask.getInputs().file( project.getBuildFile() ) - } - makeAsciidocBuildInfoTask.getOutputs().file( buildInfoDir ) - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/DocumentationTask.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/DocumentationTask.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/DocumentationTask.groovy deleted file mode 100644 index 31e2cc8..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/DocumentationTask.groovy +++ /dev/null @@ -1,292 +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.doc - -import groovy.io.FileType -import groovy.transform.CompileStatic -import groovy.transform.TypeCheckingMode -import java.security.MessageDigest -import org.apache.zest.gradle.PolygeneExtension -import org.apache.zest.gradle.release.ReleaseSpecExtension -import org.apache.zest.gradle.tasks.ExecLogged -import org.gradle.api.Action; -import org.gradle.api.DefaultTask -import org.gradle.api.file.CopySpec -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.TaskAction -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputDirectory -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.OutputDirectory -import org.gradle.process.ExecSpec - -// TODO: try to use dependencies for FOP and execute within the same JVM. -// TODO: move the bulk of resources into this plugin, instead of sitting in the project. -@CompileStatic -class DocumentationTask extends DefaultTask -{ - @Input def String docName - @Input def String docType - - @InputDirectory def File getCommonResourcesDir() { project.file( 'src/resources' ) } - @InputDirectory def File getConfigDir() { project.file( 'src/conf' ) } - @InputDirectory def File getDocsDir() { project.file( 'src/docs' ) } - @InputDirectory def File getSrcMainDir() { project.file( 'src/main' ) } - @InputDirectory def File getXslDir() { project.file( 'src/xsl' ) } - @InputDirectory def File getBuildSrcDir() { project.rootProject.file( 'buildSrc/src' ) } - - @InputFiles def getSubProjectsDocsDirs() { project.rootProject.subprojects.collect { p -> p.file( 'src/docs' ) } } - @InputFiles def getSubProjectsTestDirs() { project.rootProject.subprojects.collect { p -> p.file( 'src/test' ) } } - - @OutputDirectory def File getOutputDir() { project.file( "${ project.buildDir }/docs/${ docName }/" ) } - - @Internal def File getTempAsciidocDir() { project.file( "${ project.buildDir }/tmp-asciidoc" ) } - @Internal def File getTempDir() { project.file( "${ project.buildDir }/tmp/docs/${ docName }" ) } - - @TaskAction - def void generate() - { - installAsciidocFilters() - - [ outputDir, tempAsciidocDir, tempDir ].each { it.deleteDir() } - [ outputDir, tempAsciidocDir, tempDir ].each { it.mkdirs() } - - copySubProjectsDocsResources() - generateAsciidocAccordingToReleaseSpecification() - generateXDoc() - generateChunkedHtml() - // generateSingleHtml() - // generatePdf() - } - - def void installAsciidocFilters() - { - def digester = MessageDigest.getInstance( 'SHA' ) - def filtersDir = project.rootProject.file( 'buildSrc/src/asciidoc/filters' ) - def userHome = new File( System.getProperty( 'user.home' ) ) - def dotAsciidocFiltersDir = new File( userHome, '.asciidoc/filters' ) - def installSnippets = false - filtersDir.eachFileRecurse( FileType.FILES ) { originalFile -> - def targetFile = new File( dotAsciidocFiltersDir, - ( originalFile.toURI() as String ) - ( filtersDir.toURI() as String ) ) - if( !targetFile.exists() ) - { - installSnippets = true - } - else - { - def originalDigest = digester.digest( originalFile.bytes ) - def targetDigest = digester.digest( targetFile.bytes ) - if( originalDigest != targetDigest ) - { - installSnippets = true - } - } - } - if( installSnippets ) - { - dotAsciidocFiltersDir.mkdirs() - project.rootProject.copy { CopySpec spec -> - spec.from filtersDir - spec.into dotAsciidocFiltersDir - } - dotAsciidocFiltersDir.eachFileRecurse( FileType.FILES ) { file -> - if( file.name.endsWith( '.py' ) ) - { - chmod( file, '755' ) - } - } - println "Polygene Asciidoc Filters Installed!" - } - } - - @CompileStatic( TypeCheckingMode.SKIP ) - def void chmod( File file, String permissions ) - { - ant.chmod( file: file.absolutePath, perm: permissions ) - } - - def void copySubProjectsDocsResources() - { - project.rootProject.subprojects.each { p -> - p.copy { CopySpec spec -> - spec.from p.file( 'src/docs/resources' ) - spec.into outputDir - spec.include '**' - } - } - } - - def void generateAsciidocAccordingToReleaseSpecification() - { - def zest = project.extensions.getByType( PolygeneExtension ) - project.copy { CopySpec spec -> - spec.from docsDir - spec.into tempAsciidocDir - spec.include '**' - } - if( zest.releaseVersion ) - { - def licenseFile = new File( tempAsciidocDir, 'userguide/libraries.txt' ) - def extensionsFile = new File( tempAsciidocDir, 'userguide/extensions.txt' ) - def toolsFile = new File( tempAsciidocDir, 'userguide/tools.txt' ) - [ licenseFile, extensionsFile, toolsFile ].each { asciidocFile -> - def filteredFileContent = '' - asciidocFile.readLines().each { line -> - if( line.startsWith( 'include::' ) ) - { - def approved = false - def releaseApprovedProjects = project.rootProject.extensions. - getByType( ReleaseSpecExtension ).approvedProjects - releaseApprovedProjects.collect { it.projectDir }.each { approvedProjectDir -> - if( line.contains( "${ approvedProjectDir.parentFile.name }/${ approvedProjectDir.name }" ) ) - { - approved = true - } - } - if( approved ) - { - filteredFileContent += "$line\n" - } - } - else - { - filteredFileContent += "$line\n" - } - } - asciidocFile.text = filteredFileContent - } - } - } - - def void generateXDoc() - { - def outLog = getLogFile( 'adoc-2-docbook', 'stdout' ) - def errLog = getLogFile( 'adoc-2-docbook', 'stderr' ) - ExecLogged.execLogged( project, outLog, errLog, { ExecSpec spec -> - spec.executable = 'asciidoc' - spec.workingDir = '..' - def commonResourcesPath = relativePath( project.rootDir, commonResourcesDir ) - def asciidocConfigPath = relativePath( project.rootDir, new File( configDir, 'asciidoc.conf' ) ) - def docbookConfigPath = relativePath( project.rootDir, new File( configDir, 'docbook45.conf' ) ) - def linkimagesConfigPath = relativePath( project.rootDir, new File( configDir, 'linkedimages.conf' ) ) - def xdocOutputPath = relativePath( project.rootDir, new File( tempDir, 'xdoc-temp.xml' ) ) - def asciidocIndexPath = relativePath( project.rootDir, new File( tempAsciidocDir, "$docName/index.txt" ) ) - spec.args = [ - '--attribute', 'revnumber=' + project.version, - '--attribute', 'level1=' + ( docType == 'article' ? 1 : 0 ), - '--attribute', 'level2=' + ( docType == 'article' ? 2 : 1 ), - '--attribute', 'level3=' + ( docType == 'article' ? 3 : 2 ), - '--attribute', 'level4=' + ( docType == 'article' ? 4 : 3 ), - '--attribute', 'importdir=' + commonResourcesPath, - '--backend', 'docbook', - '--attribute', 'docinfo1', - '--doctype', docType, - '--conf-file=' + asciidocConfigPath, - '--conf-file=' + docbookConfigPath, - '--conf-file=' + linkimagesConfigPath, - '--out-file', xdocOutputPath, - asciidocIndexPath - ] - } as Action<? super ExecSpec> ) - } - - def void generateChunkedHtml() - { - project.copy { CopySpec spec -> - spec.from commonResourcesDir - spec.into outputDir - spec.include '**' - } - project.copy { CopySpec spec -> - spec.from "$docsDir/$docName/resources" - spec.into outputDir - spec.include '**' - } - def outLog = getLogFile( 'docbook-2-chunked-html', 'stdout' ) - def errLog = getLogFile( 'docbook-2-chunked-html', 'stderr' ) - ExecLogged.execLogged( project, outLog, errLog, { ExecSpec spec -> - def xsltFile = "$docsDir/$docName/xsl/chunked.xsl" - def outputPath = relativePath( project.projectDir, outputDir ) + '/' - spec.executable = 'xsltproc' - spec.args = [ - '--nonet', - '--noout', - '--output', outputPath, - xsltFile, - "$tempDir/xdoc-temp.xml" - ] - } as Action<? super ExecSpec> ) - } - - def void generateSingleHtml() - { - def outLog = getLogFile( 'docbook-2-html', 'stdout' ) - def errLog = getLogFile( 'docbook-2-html', 'stderr' ) - ExecLogged.execLogged( project, outLog, errLog, { ExecSpec spec -> - // XML_CATALOG_FILES= - String xsltFile = "$xslDir/xhtml.xsl" - spec.executable = 'xsltproc' - spec.args = [ - '--nonet', - '--noout', - '--output', "$outputDir/${ docName }.html", - xsltFile, - "$tempDir/xdoc-temp.xml" - ] - } as Action<? super ExecSpec> ) - } - - def void generatePdf() - { - // $ xsltproc --nonet ../docbook-xsl/fo.xsl article.xml > article.fo - def outLog = getLogFile( 'docbook-2-fo', 'stdout' ) - def errLog = getLogFile( 'docbook-2-fo', 'stderr' ) - ExecLogged.execLogged( project, outLog, errLog, { ExecSpec spec -> - String xsltFile = "$xslDir/fo.xsl" - spec.executable = 'xsltproc' - spec.args = [ - '--nonet', - '--output', "$tempDir/${ docName }.fo", - xsltFile, - "$tempDir/xdoc-temp.xml" - ] - } as Action<? super ExecSpec> ) - - // $ fop article.fo article.pdf - outLog = getLogFile( 'fo-2-pdf', 'stdout' ) - errLog = getLogFile( 'fo-2-pdf', 'stderr' ) - ExecLogged.execLogged( project, outLog, errLog, { ExecSpec spec -> - spec.executable = 'fop' - spec.args = [ - "$tempDir/${ docName }.fo", - "$outputDir/${ docName }.pdf" - ] - } as Action<? super ExecSpec> ) - } - - private File getLogFile( String step, String stream ) - { - return project.file( "${ project.buildDir }/tmp/${ name }/${ step }-${ stream }.log" ) - } - - private static String relativePath( File root, File target ) - { - new File( root.toURI().relativize( target.toURI() ).toString() ).path - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/ManualPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/ManualPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/ManualPlugin.groovy deleted file mode 100644 index 49cfcd5..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/ManualPlugin.groovy +++ /dev/null @@ -1,115 +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.doc - -import groovy.transform.CompileStatic -import org.apache.zest.gradle.TaskGroups -import org.apache.zest.gradle.PolygeneExtension -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.tasks.Copy - -@CompileStatic -class ManualPlugin implements Plugin<Project> -{ - static class TaskNames - { - static final String WEBSITE = "website" - static final String ARCHIVE_WEBSITE = "archiveWebsite" - static final String COPY_WEBSITE = "copyWebsite" - static final String MANUALS = "manuals" - } - - @Override - void apply( final Project project ) - { - def zest = project.extensions.getByType( PolygeneExtension ) - project.tasks.create( TaskNames.WEBSITE, DocumentationTask ) { DocumentationTask task -> - task.group = TaskGroups.DOCUMENTATION - task.description = 'Generates documentation website' - task.dependsOn project.rootProject.allprojects.findResults { Project p -> - p.tasks.findByName AsciidocBuildInfoPlugin.TASK_NAME - } - task.onlyIf { isAsciidocInstalled( project, zest ) } - task.docName = 'website' - task.docType = 'article' - } - project.tasks.create( TaskNames.ARCHIVE_WEBSITE, Copy ) { Copy task -> - task.group = TaskGroups.DOCUMENTATION - task.description = 'Copy website to ../zest-web' - task.dependsOn TaskNames.WEBSITE - task.onlyIf { isAsciidocInstalled( project, zest ) } - if( zest.developmentVersion ) - { - task.into "$project.rootProject.projectDir/../zest-web/site/content/java/develop" - } - else - { - task.into "$project.rootProject.projectDir/../zest-web/site/content/java/$project.version" - } - task.from "$project.buildDir/docs/website/" - } - project.tasks.create( TaskNames.COPY_WEBSITE, Copy ) { Copy task -> - task.group = TaskGroups.RELEASE - task.description = 'Copy website to ../zest-web LATEST' - task.dependsOn TaskNames.ARCHIVE_WEBSITE - task.onlyIf { zest.releaseVersion } - task.from "$project.rootProject.projectDir/../zest-web/site/content/java/$project.version/" - task.into "$project.rootProject.projectDir/../zest-web/site/content/java/latest/" - } - project.tasks.create( TaskNames.MANUALS ) { Task task -> - task.group = TaskGroups.DOCUMENTATION - task.description = 'Generates all documentation' - task.dependsOn TaskNames.COPY_WEBSITE - task.onlyIf { isAsciidocInstalled( project, zest ) } - } - } - - private static Boolean asciidocInstalled = null - - // Force when building a release version - // Skip if skipAsciidocIfAbsent property is set - // Skip if asciidoc is not found in PATH when building a development version - private static boolean isAsciidocInstalled( Project project, PolygeneExtension zest ) - { - if( asciidocInstalled == null ) - { - def skipAsciidocIfAbsent = project.findProperty 'skipAsciidocIfAbsent' - if( !skipAsciidocIfAbsent && zest.releaseVersion ) - { - project.logger.info 'Asciidoc tasks forced for building a release version, hope you have Asciidoc installed' - asciidocInstalled = true - } - else - { - def pathDirs = System.getenv( 'PATH' ).split( File.pathSeparator ) - def asciidocCandidates = pathDirs.collect( { String path -> - new File( path, 'asciidoc' ) - } ).flatten() as List<File> - asciidocInstalled = asciidocCandidates.findAll( { it.isFile() } ) - if( !asciidocInstalled ) - { - project.logger.lifecycle 'WARNING Asciidoc not found in PATH, manual tasks will skip\n' + - ' Please install http://www.methods.co.nz/asciidoc/' - } - } - } - return asciidocInstalled - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/XsltTask.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/XsltTask.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/XsltTask.groovy deleted file mode 100644 index d992e9f..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/doc/XsltTask.groovy +++ /dev/null @@ -1,105 +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.doc - -import groovy.transform.CompileStatic -import org.gradle.api.file.EmptyFileVisitor -import org.gradle.api.tasks.SourceTask -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.TaskAction -import org.gradle.api.file.FileVisitDetails -import javax.xml.transform.TransformerFactory -import javax.xml.transform.stream.StreamResult -import javax.xml.transform.stream.StreamSource - -/** - * Gradle task for running a set of one or more - * files through an XSLT transform. A styleSheet - * file must be specified. The source file(s) are - * configured just like any other source task: - * source <file> - * ...or... - * source <directory> - * ...and then optionally... - * include '*.xml' - * exclude, etc. - * - * One of destDir or destFile must be specified, though if - * there are multiple source files then destFile will just - * keep getting rewritten. - * - * The extension is stripped from the source files and the - * specified extension is appended (whether it is set or not) - * it defaults to no extension. - * - * Example task formatting a check style report: - * - * task checkstyleReport(type: XsltTask, dependsOn: check) { - * source project.checkstyleResultsDir - * include '*.xml' - * - * destDir = project.checkstyleResultsDir - * extension = 'html' - * - * stylesheetFile = file( 'config/checkstyle/checkstyle-noframes.xsl' ) - * } - * - * The above definition requires that the specified XSL file be - * copied in with the other checkstyle configuration files. (The - * file in the example is part of the checkstyle distribution.) - * - */ -@CompileStatic -class XsltTask extends SourceTask -{ - - @OutputDirectory - @Optional - File destDir - - @Optional - String extension - - @InputFile - File stylesheetFile - - @TaskAction - def transform() - { - def factory = TransformerFactory.newInstance() - def transformer = factory.newTransformer( new StreamSource( stylesheetFile ) ); - - getSource().visit( new EmptyFileVisitor() { - @Override - void visitFile( FileVisitDetails fvd ) - { - // Remove the extension from the file name - def name = fvd.file.name.replaceAll( '[.][^\\.]*$', '' ) - if( extension == null ) - { - extension = 'html' - } - name += '.' + extension - def destFile = new File( destDir, name ) - transformer.transform( new StreamSource( fvd.file ), new StreamResult( destFile ) ) - } - } ) - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/performance/PerformanceTestsPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/performance/PerformanceTestsPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/performance/PerformanceTestsPlugin.groovy deleted file mode 100644 index 29f1986..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/performance/PerformanceTestsPlugin.groovy +++ /dev/null @@ -1,62 +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.performance - -import groovy.transform.CompileStatic -import org.apache.zest.gradle.TaskGroups -import org.gradle.api.Action -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.plugins.JavaPluginConvention -import org.gradle.api.tasks.bundling.Jar -import org.gradle.api.tasks.testing.Test -import org.gradle.language.base.plugins.LifecycleBasePlugin - -// TODO Add profiling tasks (jfr or honest? flamegraphs?) -// TODO Add simple regression assertions, how? testing against a previous version? -@CompileStatic -class PerformanceTestsPlugin implements Plugin<Project> -{ - static class TaskNames - { - static final String PERFORMANCE_TEST = 'performanceTest' - static final String PERFORMANCE_PROFILE = 'performanceProfile' - static final String PERFORMANCE_CHECK = 'performanceCheck' - } - - @Override - void apply( final Project project ) - { - def sourceSets = project.convention.getPlugin( JavaPluginConvention ).sourceSets - sourceSets.create 'perf' - project.dependencies.add 'perfCompile', sourceSets.getByName( 'main' ).output - project.dependencies.add 'perfCompile', sourceSets.getByName( 'test' ).output - project.dependencies.add 'perfCompile', project.configurations.getByName( 'testCompile' ) - project.dependencies.add 'perfRuntime', project.configurations.getByName( 'testRuntime' ) - project.tasks.getByName( LifecycleBasePlugin.CHECK_TASK_NAME ).dependsOn 'compilePerfJava' - project.tasks.create( TaskNames.PERFORMANCE_TEST, Test, { Test task -> - task.group = TaskGroups.PERFORMANCE - task.description = 'Runs performance tests.' - task.maxParallelForks = 1 - task.forkEvery = 1L - task.testClassesDir = sourceSets.getByName( 'perf' ).output.classesDir - task.classpath = sourceSets.getByName( 'perf' ).runtimeClasspath - task.systemProperty 'jar.path', ( project.tasks.getByName( 'jar' ) as Jar ).archivePath - } as Action<Test> ) - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/publish/MavenMetadata.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/publish/MavenMetadata.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/publish/MavenMetadata.groovy deleted file mode 100644 index 7f368e6..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/publish/MavenMetadata.groovy +++ /dev/null @@ -1,281 +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.publish - -import org.gradle.api.artifacts.maven.MavenDeployer - -class MavenMetadata -{ - static void applyTo( MavenDeployer mavenDeployer ) - { - mavenDeployer.pom { - project { - url 'https://zest.apache.org/' - organization { - name 'The Apache Software Foundation' - url 'https://apache.org/' - } - inceptionYear '2007' - issueManagement { - system 'jira' - url 'https://issues.apache.org/jira/browse/ZEST' - } - scm { - url "https://github.com/apache/zest-java" - connection "scm:git:https://git-wip-us.apache.org/repos/asf/zest-java.git" - developerConnection "scm:git:https://git-wip-us.apache.org/repos/asf/zest-java.git" - } - licenses { - license { - name 'Apache License, version 2.0.' - url 'http://www.apache.org/licenses/LICENSE-2.0' - } - } - mailingLists { - mailingList { - name 'Users List' - subscribe '[email protected]' - unsubscribe '[email protected]' - post '[email protected]' - archive 'https://mail-archives.apache.org/mod_mbox/zest-users/' - otherArchives { - otherArchive 'https://www.apache.org/foundation/mailinglists.html#archives' - } - } - mailingList { - name 'Development List' - subscribe '[email protected]' - unsubscribe '[email protected]' - post '[email protected]' - archive 'https://mail-archives.apache.org/mod_mbox/zest-dev/' - otherArchives { - otherArchive 'https://www.apache.org/foundation/mailinglists.html#archives' - } - } - mailingList { - name 'Commits List' - subscribe '[email protected]' - unsubscribe '[email protected]' - post '[email protected]' - archive 'https://mail-archives.apache.org/mod_mbox/zest-commits/' - otherArchives { - otherArchive 'https://www.apache.org/foundation/mailinglists.html#archives' - } - } - } - developers { - developer { - id '[email protected]' - name 'Niclas Hedhman' - email '[email protected]' - roles { - role 'Core Team' - } - organizationUrl 'http://zest.apache.org' - timezone 'UTC+8' - } - developer { - id 'rickardoberg' - name 'Rickard \u00F6berg' - email '[email protected]' - roles { - role 'Core Team' - } - url 'http://www.neotechnology.com' - organization 'Neo Technology AB' - organizationUrl 'http://www.neotechnology.com' - timezone 'UTC+8' - } - developer { - id '[email protected]' - name 'Edward Yakop' - email '[email protected]' - roles { - role 'Core Team' - } - organizationUrl 'http://zest.apache.org' - timezone 'UTC+8' - } - developer { - id '[email protected]' - name 'Alin Dreghiciu' - email '[email protected]' - roles { - role 'Core Team' - } - organizationUrl 'http://zest.apache.org' - timezone 'UTC+2' - } - developer { - id 'mesirii' - name 'Michael Hunger' - email '[email protected]' - roles { - role 'Core Team' - } - timezone 'CET' - } - - developer { - id "muhdkamil" - name "Muhd Kamil bin Mohd Baki" - roles { - role 'Platform Team' - } - timezone "UTC+8" - } - - developer { - id "[email protected]" - name "David Leangen" - organization "Bioscene" - email "[email protected]" - roles { - role 'Platform Team' - } - timezone "UTC+9" - } - - developer { - id "[email protected]" - name "Sonny Gill" - email "[email protected]" - roles { - role 'Community Team' - } - timezone "UTC+8" - } - - developer { - id "taowen" - name "Tao Wen" - organization "" - email "[email protected]" - roles { - role 'Community Team' - } - timezone "UTC+8" - } - - developer { - id "thobe" - name "Tobias Ivarsson" - email "[email protected]" - url "http://www.neotechnology.com" - organization "NeoTechnology" - organizationUrl "http://www.neotechnology.com" - roles { - role "Platform Team" - } - timezone "CET" - } - - developer { - id "boon" - name "Lan Boon Ping" - email "[email protected]" - roles { - role 'Platform Team' - } - timezone "UTC+8" - } - - developer { - id "[email protected]" - name "Jan Kronquist" - email "[email protected]" - organization "Jayway" - roles { - role 'Platform Team' - } - timezone "CET" - } - - developer { - id "nmwael" - name "Nino Saturnino Martinez Vazquez Wael" - roles { - role 'Platform Team' - } - timezone "CET" - } - - developer { - id "[email protected]" - name "Peter Neubauer" - email "[email protected]" - roles { - role 'Platform Team' - } - timezone "CET" - } - - developer { - id "rwallace" - name "Richard Wallace" - email "[email protected]" - roles { - role 'Platform Team' - } - timezone "UTC-7" - } - - developer { - id "[email protected]" - name "Sianny Halim" - email "[email protected]" - roles { - role 'Platform Team' - } - timezone "UTC+8" - } - - developer { - id "[email protected]" - name "Paul Merlin" - email "[email protected]" - roles { - role 'Core Team' - } - timezone "CET" - } - - developer { - id "[email protected]" - name "Stanislav Muhametsin" - email "[email protected]" - roles { - role 'Platform Team' - } - timezone "UTC+2" - } - - developer { - id "tonny" - name "Tonny Kohar" - roles { - role "Community Team" - } - email "[email protected]" - timezone "UTC+7" - } - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/buildSrc/src/main/groovy/org/apache/zest/gradle/publish/PublishingPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/publish/PublishingPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/publish/PublishingPlugin.groovy deleted file mode 100644 index 92b00ca..0000000 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/publish/PublishingPlugin.groovy +++ /dev/null @@ -1,183 +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.publish - -import groovy.transform.CompileStatic -import org.apache.zest.gradle.PolygeneExtension -import org.apache.zest.gradle.release.ReleaseSpecExtension -import org.gradle.api.GradleException -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.artifacts.maven.MavenDeployer -import org.gradle.api.artifacts.maven.MavenDeployment -import org.gradle.api.internal.plugins.DslObject -import org.gradle.api.plugins.MavenRepositoryHandlerConvention -import org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer -import org.gradle.api.publication.maven.internal.deployer.MavenRemoteRepository -import org.gradle.api.tasks.Upload -import org.gradle.plugins.signing.Sign -import org.gradle.plugins.signing.SigningExtension - -/** - * Publishing. - * - * <strong>Configuration</strong> - * - * By default RELEASES are signed, SNAPSHOTS are not. - * Signing can be turned on or off by setting the {@literal uploadSigned} property. - * - * By default RELEASES must satisfy {@link org.apache.zest.gradle.release.ModuleReleaseSpec}, SNAPSHOT don't. - * This can be turned on or off by setting the {@literal uploadReleaseSpec} property. - * - * By default RELEASES and SNAPSHOTS are uploaded using HTTP. - * Used Wagon can be overridden by setting the {@literal uploadWagon} property. - * - * By default RELEASES and SNAPSHOTS are uploaded to Apache Nexus. - * Target repository can be overridden by setting the {@literal uploadRepository} property. - * - * No username/password is provided by default. - * If needed set them using the uploadUsername and {@literal uploadPassword} properties. - */ -@CompileStatic -class PublishingPlugin implements Plugin<Project> -{ - static final String WAGON_HTTP = 'org.apache.maven.wagon:wagon-http:2.2' - static final String WAGON_SSH = 'org.apache.maven.wagon:wagon-ssh:2.2' - static final String WAGON_WEBDAV = 'org.apache.maven.wagon:wagon-webdav:1.0-beta-2' - - static final String RELEASES_REPOSITORY_NAME = 'apache.releases.https' - static final String RELEASES_REPOSITORY_URL = 'https://repository.apache.org/service/local/staging/deploy/maven2' - static final String SNAPSHOTS_REPOSITORY_NAME = 'apache.snapshots.https' - static final String SNAPSHOTS_REPOSITORY_URL = 'https://repository.apache.org/content/repositories/snapshots' - - static class Config - { - boolean snapshots - boolean releases - boolean signed - boolean releaseSpec - String wagon - String repositoryName - String repositoryUrl - String username - String password - } - - @Override - void apply( final Project project ) - { - Config config = configFor( project ) - applyWagonConfiguration( project, config ) - configureSigning( project, config ) - configureUploadArchives( project, config ) - configureMavenMetadata( project ) - applyMavenPublishAuth( project ) - } - - private static Config configFor( Project project ) - { - def zest = project.extensions.getByType( PolygeneExtension ) - def config = new Config() - config.snapshots = zest.developmentVersion - config.releases = zest.releaseVersion - config.signed = project.findProperty( 'uploadSigned' ) ?: config.releases - config.releaseSpec = project.findProperty( 'uploadReleaseSpec' ) ?: config.releases - config.wagon = project.findProperty( 'uploadWagon' ) ?: WAGON_HTTP - config.repositoryName = project.findProperty( 'uploadRepositoryName' ) ?: - config.releases ? RELEASES_REPOSITORY_NAME : SNAPSHOTS_REPOSITORY_NAME - config.repositoryUrl = project.findProperty( 'uploadRepository' ) ?: - config.releases ? RELEASES_REPOSITORY_URL : SNAPSHOTS_REPOSITORY_URL - config.username = project.findProperty( 'uploadUsername' ) - config.password = project.findProperty( 'uploadPassword' ) - return config - } - - private static void applyWagonConfiguration( Project project, Config config ) - { - project.configurations.create( 'deployersJars' ) - project.dependencies.add( 'deployersJars', config.wagon ) - } - - private static void configureSigning( Project project, Config config ) - { - project.plugins.apply 'signing' - def signing = project.extensions.getByType( SigningExtension ) - signing.required = config.signed - signing.sign project.configurations.getByName( 'archives' ) - def signArchives = project.tasks.getByName( 'signArchives' ) as Sign - signArchives.onlyIf { !project.findProperty( 'skipSigning' ) } - } - - private static void configureUploadArchives( Project project, Config config ) - { - project.plugins.apply 'maven' - def uploadArchives = project.tasks.getByName( 'uploadArchives' ) as Upload - uploadArchives.doFirst { - if( project.version == "0" ) - { - throw new GradleException( "'version' must be given as a system property to perform a release." ) - } - } - uploadArchives.onlyIf { - def notSkipped = !project.hasProperty( 'skipUpload' ) - def approvedProject = project.extensions.getByType( ReleaseSpecExtension ).approvedProjects.contains( project ) - return notSkipped && ( !config.releaseSpec || ( approvedProject || project == project.rootProject ) ) - } - uploadArchives.dependsOn project.tasks.getByName( 'check' ) - def repositoriesConvention = new DslObject( uploadArchives.repositories ) - .getConvention() - .getPlugin( MavenRepositoryHandlerConvention ) - def mavenDeployer = repositoriesConvention.mavenDeployer() as DefaultGroovyMavenDeployer - if( config.signed ) - { - mavenDeployer.beforeDeployment { MavenDeployment deployment -> - project.extensions.getByType( SigningExtension ).signPom( deployment ) - } - } - mavenDeployer.configuration = project.configurations.getByName( 'deployersJars' ) - def repository = new MavenRemoteRepository() - repository.id = config.repositoryName - repository.url = config.repositoryUrl - if( config.username ) - { - repository.authentication.userName = config.username - repository.authentication.password = config.password - } - if( config.releases ) - { - mavenDeployer.repository = repository - } - else - { - mavenDeployer.snapshotRepository = repository - } - } - - private static void configureMavenMetadata( Project project ) - { - def uploadArchives = project.tasks.getByName( 'uploadArchives' ) as Upload - def mavenDeployer = uploadArchives.repositories.getByName( 'mavenDeployer' ) as MavenDeployer - MavenMetadata.applyTo( mavenDeployer ) - } - - private static void applyMavenPublishAuth( final Project project ) - { - // Bug in maven-publish-auth require apply after uploadArchives setup - project.plugins.apply 'maven-publish-auth' - } -}
