Am 14.09.11 22:53, schrieb John E. Vincent:
I was hoping someone could help me with a couple of issues in a multi-project
build. I'm attempting to convert this from Maven2. I'm also not in a
position to radically change the directory structure and artifact names.
Also I'm not a java developer (just ruby and python) so please consider that
;)

For reference: https://gist.github.com/3f71c7e8ea55c35168af

Above is a pretty standard build with subprojects. Everything is working
perfectly with one exception which leads to my first question:

How to I stop generating an empty jar file in 'common/dao/build/libs'?
In your build.gradle file, you apply the java plugin for EACH subproject. Having a nested setup like yours with dao:hibernate, dao:voldemort, gradle adds implicitly the subproject :dao. Since the java plugin adds the jar task, the dao project creates an empty jar. To avoid applying plugins to the dao project you can rewrite your subprojects closure to add an additional check that root projects don't apply any plugins and settings:
----------
subprojects {
  if(!subprojects){

      apply plugin: 'java'
      apply plugin: 'maven'
      apply plugin: 'artifactory'
      apply plugin: 'project-reports'

      group = "com.myorg.common"
      projectName = "common"
      version = "1.0-SNAPSHOT"

      defaultTasks 'clean','assemble'

      task mappings << {
        println conf2ScopeMappings.mappings
      }

      configurations {
        provided
        testCompile.extendsFrom provided
        compile.transitive = true
      }

      publish {
repoKey = version.contains("-SNAPSHOT") ? "libs-snapshots-local" : "libs-releases-local"
        username = artifactoryPublishUsername
        password = artifactoryPublishPassword
      }

      resolve {
        contextUrl = artifactoryContextUrl
        repository {
          repoKey = artifactoryResolveRepoKey
          username = artifactoryPublishUsername
          password = artifactoryPublishPassword
        }
      }

      sourceSets {
        main {
          compileClasspath += configurations.provided
        }
      }

      jar {
        baseName = projectName + '-' + baseName
      }
    }
}
----------



The common-dao I WANT is in 'common/dao/common/build/libs' and dao is
obviously just a containing folder)? I've seen the references to the gradle
project's build.gradle and 'def groovyProjects()' but I'm just not up to my
groovy and gradle skills yet to parse that myself.

The second question is more of a shortcut one:

What's the best way to DRY up the dao:* subproject specific settings.
There's obviously a pattern there that I can address programatically. I'm
guessing some sort of array and iterator would be involved but again, my
groovy isn't there yet.
On your multiproject build your setup I think the follow should work to get a more DRY script:
--------------
project(':dao') { daoProj ->
    subprojects { daoSubProj ->
        jar {
            baseName = "$projectName-${daoProj.name}-${daoSubProj.name}"
        }
    }
}
-------------

regards,
René

--
-----------------------
regards René

rene groeschke
http://www.breskeby.com
@breskeby


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to