Ok,

Searching around I found this approach, which works:

class Version {
    String defaultVersion='0.1'
    String releaseType='SNAPSHOT'
    def project

    String toString() {
        switch (project.name) {
            case 'myProject':
                "1.0-${releaseType}"
            default:
                "${defaultVersion}-${releaseType}"
        }
    }
}

then:
subprojects {
    version=new Version(project:project).toString()


But I feel like there still is something I'm not quite confortable with in
the area of configuration-time dependencies. I would love to see a
comprehensive best-practice example. Is there a book I could buy?

On Fri, May 20, 2011 at 10:37 AM, Luis <[email protected]> wrote:

> It can't be that this is such a weird case. I'm sure I'm nit doing it
> right. A nudge in the right direction maybe.
>
> Sent from my iPad
>
> On 19/05/2011, at 18:30, Luis Muniz <[email protected]> wrote:
>
> Hi
>
> I'm discovering gradle, and though it is really nice, the learning curve is
> steeper than I thought when you start doing funkier stuff. This is obviously
> because I am uninformed both in the gradle implementatino and in the
> complexity of building engines.
>
> This is my issue
>
> I am trying to factor out common tasks to the parent project, to do this, I
> have defined the tasks in the following way, on the root project:
>
> subprojects {
>     apply plugin: 'groovy'
>     apply plugin: 'maven'
>     apply from: "$rootDir/cobertura.gradle"
>     apply from: "$rootDir/idea.gradle"
>
>     repositories {
> [...]
>     }
>
>     configurations {
> [...]
>     }
>
>     dependencies {
> [...]
>     }
>
> [...(etc, etc) ]
>
>    uploadArchives {task->
>         repositories.mavenDeployer {
>             uniqueVersion = true
>             name = 'httpDeployer'
>             configuration = configurations.deployerJars
>             def repoURL = " <http://artifactory:8081/artifactory>
> http://artifactory:8081/artifactory";
>             repoURL += version.contains("-SNAPSHOT") ?
> "/libs-snapshots-local" : "/libs-releases-local"
>
>             repository(url: repoURL) {
>                 authentication(userName: "a", password: "b")
>             }
>         }
>     }
>
> }
>
>
>
> in my subproject's build.gradle, i define:
>
> version = '1.0-SNAPSHOT'
>
> dependencies {
> [...]
> }
>
>
>
> However, the version property seems to not be defined in time for the
> uploadJars task to get it from the subproject.
>
> I have been trying different things now, until I realized that I'm possibly
> taking the problem the wrong way around.
>
> I just would like to check with the community that this is the way to do
> this.
>
> Thanks for any help.
>
> Luis
>
>
>
>
>

Reply via email to