new sourceSets{} behaviour

View: New views
3 Messages — Rating Filter:   Alert me  

new sourceSets{} behaviour

by Narco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I see there is huge changes in source folders managment. Yes, it looks very nice but my old configuration is not working anymore and I can`t reproduce it with sourceSets. This was before and working as I want:
resourceDirNames = new LinkedList()
    String mainResourcesRootRel = "/main/resources"
    if(project.hasProperty('configName')){
        if(project.hasProperty('configType')){
            resourceDirNames.add "$mainResourcesRootRel/${configName}/${configType}"
        }
        resourceDirNames.add "$mainResourcesRootRel/${configName}/default"
    }
    resourceDirNames.add "$mainResourcesRootRel/default"

Now I`m trying to rewrite like this:
sourceSets {
                    main {
                        resources {
                            srcDir "src/main/resources/default"
                            srcDir "src/main/resources/${configName}/default"
                        }
                    }
                }

The result is wrong. It seems like only first srcDir definition is used and default folder is still used too.

Re: new sourceSets{} behaviour

by Adam Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Narco wrote:

> I see there is huge changes in source folders managment. Yes, it looks very
> nice but my old configuration is not working anymore and I can`t reproduce
> it with sourceSets. This was before and working as I want:
> resourceDirNames = new LinkedList()
>     String mainResourcesRootRel = "/main/resources"
>     if(project.hasProperty('configName')){
>         if(project.hasProperty('configType')){
>             resourceDirNames.add
> "$mainResourcesRootRel/${configName}/${configType}"
>         }
>         resourceDirNames.add "$mainResourcesRootRel/${configName}/default"
>     }
>     resourceDirNames.add "$mainResourcesRootRel/default"
>
>  

You should be able to add this to the end of the above, and it will work
as it used to:

sourceSets.main.resources.srcDirs = resourceDirNames

> Now I`m trying to rewrite like this:
> sourceSets {
>                     main {
>                         resources {
>                             srcDir "src/main/resources/default"
>                             srcDir
> "src/main/resources/${configName}/default"
>                         }
>                     }
>                 }
>
> The result is wrong. It seems like only first srcDir definition is used and
> default folder is still used too.
>  

The sourceSets.main.resources.srcDir() method appends a directory to the
list, so it will continue to use the default directory. You need to set
the srcDirs property to replace them, something like:

sourceSets.main.resources.srcDirs = ["src/main/resources/default",
"src/main/resource/${configName}/default"]


--
Adam Murdoch
Gradle Developer
http://www.gradle.org


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

    http://xircles.codehaus.org/manage_email



Re: new sourceSets{} behaviour

by Narco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Works! Thank You!

Adam Murdoch-2 wrote:
You should be able to add this to the end of the above, and it will work
as it used to:

sourceSets.main.resources.srcDirs = resourceDirNames

The sourceSets.main.resources.srcDir() method appends a directory to the
list, so it will continue to use the default directory. You need to set
the srcDirs property to replace them, something like:

sourceSets.main.resources.srcDirs = ["src/main/resources/default",
"src/main/resource/${configName}/default"]


--
Adam Murdoch
Gradle Developer
http://www.gradle.org


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

    http://xircles.codehaus.org/manage_email