build: decouple project names from built artifact names we can now do:
./gradlew core:runtime:test instead of: ./gradlew org.apache.polygene.core:org.apache.polygene.core.runtime:test so much less typing produced artifacts are the same as before Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/05c8141f Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/05c8141f Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/05c8141f Branch: refs/heads/develop Commit: 05c8141f11277feb87eb0a1a35fe5300ce75d106 Parents: cba29f6 Author: Paul Merlin <[email protected]> Authored: Sun Dec 18 01:36:08 2016 +0100 Committer: Paul Merlin <[email protected]> Committed: Sun Dec 18 01:36:08 2016 +0100 ---------------------------------------------------------------------- .../polygene/gradle/AllProjectsPlugin.groovy | 4 +-- .../polygene/gradle/CodeProjectsPlugin.groovy | 26 ++++++++++++++++ .../polygene/gradle/PolygeneExtension.groovy | 8 ++--- .../polygene/gradle/RootProjectPlugin.groovy | 2 +- settings.gradle | 32 ++------------------ .../introduction/thirtyminutes/build.gradle | 2 +- 6 files changed, 36 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/05c8141f/buildSrc/src/main/groovy/org/apache/polygene/gradle/AllProjectsPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/AllProjectsPlugin.groovy b/buildSrc/src/main/groovy/org/apache/polygene/gradle/AllProjectsPlugin.groovy index 6c9a2c0..0edf1e2 100644 --- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/AllProjectsPlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/AllProjectsPlugin.groovy @@ -42,9 +42,9 @@ class AllProjectsPlugin implements Plugin<Project> void apply( final Project project ) { project.defaultTasks = [ 'classes', 'test' ] - project.group = project.name == 'org.apache.polygene' ? + project.group = project.rootProject == project ? 'org.apache.polygene' : - project.name.substring( 0, project.name.lastIndexOf( '.' ) ) + "org.apache.polygene.${ project.path.split( ':' ).drop( 1 ).dropRight( 1 ).join( '.' ) }" applyDefaultVersion( project ) applyPolygeneExtension( project ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/05c8141f/buildSrc/src/main/groovy/org/apache/polygene/gradle/CodeProjectsPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/CodeProjectsPlugin.groovy b/buildSrc/src/main/groovy/org/apache/polygene/gradle/CodeProjectsPlugin.groovy index 6aa345b..5eeaca0 100644 --- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/CodeProjectsPlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/CodeProjectsPlugin.groovy @@ -25,6 +25,7 @@ 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.bundling.AbstractArchiveTask import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.jvm.tasks.Jar import org.gradle.testing.jacoco.plugins.JacocoPluginExtension @@ -49,6 +50,7 @@ class CodeProjectsPlugin implements Plugin<Project> configureJar( project ) configureSupplementaryArchives( project ) + configureArchivesBaseName( project ) configureJacoco( project ) configureCheckstyle( project ) @@ -94,6 +96,30 @@ class CodeProjectsPlugin implements Plugin<Project> project.artifacts.add( 'archives', javadocJar ) } + private static void configureArchivesBaseName( Project project ) + { + project.tasks.withType( AbstractArchiveTask ) { AbstractArchiveTask task -> + def toName = { List<String> path -> path.drop( 1 ).join( '.' ) } + def path = project.path.split( ':' ).drop( 1 ) as List<String> + if( path[ 0 ] == 'libraries' ) + { + task.baseName = "org.apache.polygene.library.${ toName( path ) }" + } + else if( path[ 0 ].endsWith( 's' ) ) + { + task.baseName = "org.apache.polygene.${ path[ 0 ].substring( 0, path[ 0 ].length() - 1 ) }.${ toName( path ) }" + } + else if( path.size() > 1 ) + { + task.baseName = "org.apache.polygene.${ path[ 0 ] }.${ toName( path ) }" + } + else + { + task.baseName = "org.apache.polygene.${ path[ 0 ] }" + } + } + } + private static void configureJacoco( Project project ) { def dependencies = project.rootProject.extensions.getByType( DependenciesDeclarationExtension ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/05c8141f/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy b/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy index 41e472a..f20a610 100644 --- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy +++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/PolygeneExtension.groovy @@ -54,22 +54,22 @@ class PolygeneExtension private Dependency core( String name ) { - return dependency( 'org.apache.polygene.core', "org.apache.polygene.core.$name" ) + return dependency( 'core', name ) } Dependency library( String name ) { - return dependency( 'org.apache.polygene.libraries', "org.apache.polygene.library.$name" ) + return dependency( 'libraries', name ) } Dependency extension( String name ) { - return dependency( 'org.apache.polygene.extensions', "org.apache.polygene.extension.$name" ) + return dependency( 'extensions', name ) } Dependency tool( String name ) { - return dependency( 'org.apache.polygene.tools', "org.apache.polygene.tool.$name" ) + return dependency( 'tools', name ) } private Dependency dependency( String group, String name ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/05c8141f/buildSrc/src/main/groovy/org/apache/polygene/gradle/RootProjectPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/RootProjectPlugin.groovy b/buildSrc/src/main/groovy/org/apache/polygene/gradle/RootProjectPlugin.groovy index 78857ea..12f2601 100644 --- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/RootProjectPlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/RootProjectPlugin.groovy @@ -95,7 +95,7 @@ class RootProjectPlugin implements Plugin<Project> buildAll.dependsOn 'javadocs', 'check', 'jar', project.subprojects.collect { p -> p.tasks.getByName( 'dependencyReport' ) }, project.subprojects.collect { p -> p.tasks.getByName( 'assemble' ) }, - ':org.apache.polygene.manual:website' + ':manual:website' } private static void applyPlugins( Project project ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/05c8141f/settings.gradle ---------------------------------------------------------------------- diff --git a/settings.gradle b/settings.gradle index a78cd93..d789e08 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,10 +14,10 @@ * 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. - * - * */ +rootProject.name = 'polygene-java' + include 'core:api', 'core:spi', 'core:testsupport', @@ -98,31 +98,3 @@ include 'core:api', 'tutorials:services', 'tests:regression', 'tests:performance' - -rootProject.name = "org.apache.polygene" - -validateProject(rootProject, "") - -def validateProject(project, parentName) -{ - assert project.projectDir.isDirectory() - if( new File("$project.projectDir/src/main/java").exists() ) - { - assert project.buildFile.isFile() - } - if( parentName == 'org.apache.polygene.libraries' ) - { - parentName = 'org.apache.polygene.library' - } - if( parentName.endsWith('s') ) - { - parentName = parentName.substring(0, parentName.length() - 1) - } - if( parentName.length() > 0 ) - { - project.name = parentName + "." + project.name - } - project.children.each { child -> - validateProject(child, project.name) - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/05c8141f/tutorials/introduction/thirtyminutes/build.gradle ---------------------------------------------------------------------- diff --git a/tutorials/introduction/thirtyminutes/build.gradle b/tutorials/introduction/thirtyminutes/build.gradle index d313fb6..dc0eeba 100644 --- a/tutorials/introduction/thirtyminutes/build.gradle +++ b/tutorials/introduction/thirtyminutes/build.gradle @@ -24,7 +24,7 @@ jar { manifest { name = "Apache Polygene⢠Tutorial - 30 minute Introduction" } dependencies { compile polygene.core.bootstrap - compile project( ':org.apache.polygene.tutorials:org.apache.polygene.tutorial.introduction:org.apache.polygene.tutorial.introduction.tenminutes' ) + compile project( ':tutorials:introduction:tenminutes' ) runtime polygene.core.runtime
