On Dec 26, 2008, at 9:46 PM, Les Hazlewood wrote:

No worries Hans, thanks for the support.  It is a great tool that is
only getting better ;)

But on this solution:

archive_jar.baseName = "$productName-$task.project.name"


That line would have to be in the overridden 'init' task, wouldn't it?

Right.

But you could do instead (without creating an extra task)

archive_jar.baseName = "$productName-$name"

This works as the variables are first resolved against the subproject.

- Hans



That is, it can't be a child of the subprojects {} closure since that
is executed during the configuration phase, which doesn't have a task
reference - right?

Regards,

Les

On Fri, Dec 26, 2008 at 3:18 PM, Hans Dockter <[email protected]> wrote:

On Dec 26, 2008, at 5:24 PM, Les Hazlewood wrote:

Hi all,

I've just spent my first day or two using Gradle, and before I go
futher, I just want to say _Thank You_.  It is a superb tool, and I
love how groovy's elegant simplicity makes build environments
(especially multi-project environments) much more tolerable.
Thanks!!!

Now my question:

I've been racking my brain on this problem for the last few hours, and after feeling like I've memorized the user guide, I still can't figure
out the solution.  Hopefully you can enlighten me.

I have a project with sub-projects (I call a sub-project a 'module'
below):

greatProduct
| -- moduleA
| -- moduleB
...
| -- build.gradle
| -- settings.gradle

When I run 'gradle libs', what I want generated, for each module, is
the following,

moduleA/build/greatProduct-moduleA-0.1.0-SNAPSHOT.jar
moduleB/build/greatProduct-moduleB-0.1.0-SNAPSHOT.jar

In the beginning of Gradle we had this naming schema as default. I'm
wondering if should offer some simple switch to activate a long naming
schema (vs the short default naming schema).

...
and so on, for each module. Currently the two sub-projects don't have
a build.gradle file.

So, right now, I can't for the life of me get it to build anything
other than the following:

moduleA/build/moduleA-0.1.0.jar
moduleB/build/moduleB-0.1.0.jar

I'm putting the logic to append the -SNAPSHOT designator, as well as
to do the artifact renaming (and manifest name changes) in the init
method. This isn't working. Any reason why? Any help is _sincerely_
appreciated!

Unfortunately you ran into a Gradle bug:
http://jira.codehaus.org/browse/GRADLE-330

A fix for this will be provided with the 0.5.1 release.

Until then you can do as a work around:
subprojects {
      ...
      usePlugin('java')
      ...
// archive_jar is the name of the default archive task added by the Java plugin. If you add other archives tasks to your project, you have to
add this name as well.
      archive_jar.baseName = "$productName-$task.project.name"
}

I'm sorry that this bug has cost you so much time.

- Hans



Thanks!

Here is my relevant part of the master build.gradle file:
---------------------------------------------

dependsOnChildren()

productName = "greatProduct"
majorVersion = 0
minorVersion = 1
patchVersion = 0
snapshotDesignation = "-SNAPSHOT"
version = majorVersion + "." + minorVersion + "." + patchVersion

//we use Nexus as our internal company artifact repository:
artifactRepositoryRoot =
"http://ourNexusHost:8080/nexus/content/repositories";

subprojects {

usePlugin("java")

dependencies {
addMavenStyleRepo("snapshots", artifactRepositoryRoot + "/ snapshots") addMavenStyleRepo("thirdparty", artifactRepositoryRoot + "/ thirdparty")
addMavenStyleRepo("releases", artifactRepositoryRoot + "/releases")
addMavenStyleRepo("public", artifactRepositoryRoot + "/central")
}

/**
* Initialization task
*/
createTask("init", overwrite: true) {task ->
archivesBaseName = "$productName-$task.project.name"

//modify the version to be a snapshot if this isn't a release build:
if (!build.taskGraph.hasTask(":release") &&
!version.endsWith(snapshotDesignation)) {
version += snapshotDesignation;
}

manifest.mainAttributes(['Implementation-Title':
"$archivesBaseName",'Implementation-Version': "$version"])
}

resources.excludes("**/*.java")

sourceCompatibility = 1.5
targetCompatibility = 1.5
test {
include '**/*Test.class'
exclude '**/Abstract*'
}
}

//project dependencies below here

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

 http://xircles.codehaus.org/manage_email



--
Hans Dockter
Gradle Project lead
http://www.gradle.org





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

 http://xircles.codehaus.org/manage_email




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

   http://xircles.codehaus.org/manage_email



--
Hans Dockter
Gradle Project lead
http://www.gradle.org





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

   http://xircles.codehaus.org/manage_email


Reply via email to