Hi Luke,
Thanks for your reply. I did a lot of trial and error and I figured
out that this works:
------subprojectfile------
dependencies {
compile getDependency('ccutil')
}
def getDependency(projectname) {
compDir = file(rootDir.getAbsolutePath() + '/components/' +
projectname);
if(compDir.exists() && compDir.directory) {
return project(':'+projectname)
}
else {
return 'Cordys:' + projectname + ':unspecified'
}
}
------------
But if I split this in two files, the problem happens
-----rootfile-------
subprojects {
apply plugin: 'java'
def getDependency(projectname) {
compDir = file(rootDir.getAbsolutePath() + '/components/' +
projectname);
if(compDir.exists() && compDir.directory) {
return project(':'+projectname)
}
else {
return 'Cordys:' + projectname + ':unspecified'
}
}
}
------subprojectfile------
dependencies {
compile getDependency('ccutil')
}
------------
FAILURE: Build failed with an exception.
* Where:
Script 'E:\svn\batic-wip\build.gradle' line: 15
* What went wrong:
Could not compile script 'E:\svn\batic-wip\build.gradle'.
Cause: startup failed:
script 'E:\svn\batic-wip\build.gradle': 15: Unknown type: METHOD_DEF
at line: 15 column: 2. File: build_5ela0dboa4kgt4gpjovfa4ojpk @ line
15, column 2.
def getDependency(projectname) {
^
----------------
I tried to move the method out of subprojects scope, but then Gradle
complains "Could not find method getDependency() for arguments
[ccutil] on project ':eibxml'."
Any idea?
Thanks,
Gerwin
On Sat, Jun 18, 2011 at 11:02, Luke Daley <[email protected]> wrote:
>
> On 18/06/2011, at 1:13 AM, Gerwin Jansen wrote:
>
>> I have the following use case:
>> My multi-project setup needs to support subversion partial check-out.
>> This means that my subprojects are sometimes part of the check-out and
>> sometimes not. So a subproject is sometimes a project dependency and
>> sometimes an artifact dependency.
>>
>> I tried to write a method/function to achieve this result:
>> def createDependency(projectname)
>> {
>> if(exists("components/" + projectname)
>> {
>> dependencies { compile project(projectname) }
>> }
>> else
>> {
>> dependencies { compile "com.cordys:" + projectname + ":SNAPSHOT" }
>> }
>> }
>>
>> But I'm getting stuck with this. After diving more deeply in Gradle I
>> feel like adding a ProjectEvaluationListener. But this is completely
>> new terrain for me.
>> Does anyone know the solution? Or a solution direction?
>> Any help is highly appreciated.
>
>
> What problems did you have?
>
> This is a suitable approach, but you are also going to need some code in
> settings.groovy to only include the subprojects that were checked out.
>
> --
> Luke Daley
> Principal Engineer, Gradleware
> http://gradleware.com
>
> Please vote Gradle for JAX Awards » http://vote.jax-awards.com
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--
Gerwin Jansen
Software Engineer
[email protected]
www.cordys.com
T +31 341 375685 • M +31 6 1374 6668
CORDYS – Improving Business Operations
Cordial 2011 | September 13 - 15, 2011 | Register Now
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email