Compile Inculde/Exclude

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Compile Inculde/Exclude

chrishane@gmail.com
Is it possible to have an includes/excludes directive on the compile task?

I am building a java project and our current build scripts compile specific directories for specific build targets.  Until I can refactor the directory structure, I need to compile only certain directories.

Thanks,
Chris....
Reply | Threaded
Open this post in threaded view
|

Re: Compile Inculde/Exclude

hans_d
Administrator
Hi Chris,

On May 10, 2008, at 12:49 AM, chrishane wrote:

Is it possible to have an includes/excludes directive on the compile task?

I am building a java project and our current build scripts compile specific
directories for specific build targets.  Until I can refactor the directory
structure, I need to compile only certain directories.

I have been surprised myself when I discovered that the Gradle Compile task does not offer this.

On the other hand it is a good showcase that Gradle doesn't lock you in. If Gradle where just a big framework you might had to wait for the next release to get this feature. But as Gradle's build by convention behavior is build upon a general purpose build DSL there is a work around.

compile.actions[0] = {    ant {        mkdir(dir: classesDir)        javac(includeAntRuntime: false,                srcdir: srcDirs.join(':'),                destdir: classesDir,                classpath: dependencies.antpath('compile'),                target: targetCompatibility,                source: sourceCompatibility,                includes: 'org/gradle/webapp1/')    }}
This replaces the build in compile behavior with something that solves your problem. We simply use the javac ant task and feed it with the project properties. Additionally we use javac's includes property to filter packages or whatever we want to filter. There is also an excludes property available.
We are not saying this is very convenient but not less convenient compared to an ant build. 
I have filed an issue for this: http://jira.codehaus.org/browse/GRADLE-89
This is going to be fixed in the next release.
- Hans


Thanks,
Chris....
-- 
Sent from the gradle-user mailing list archive at Nabble.com.


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




--
Hans Dockter
Gradle Project lead




Reply | Threaded
Open this post in threaded view
|

Re: Compile Inculde/Exclude

hans_d
Administrator

On May 11, 2008, at 8:50 AM, Hans Dockter wrote:
Hi Chris,

On May 10, 2008, at 12:49 AM, chrishane wrote:

Is it possible to have an includes/excludes directive on the compile task?

I am building a java project and our current build scripts compile specific
directories for specific build targets.  Until I can refactor the directory
structure, I need to compile only certain directories.

I have been surprised myself when I discovered that the Gradle Compile task does not offer this.

On the other hand it is a good showcase that Gradle doesn't lock you in. If Gradle where just a big framework you might had to wait for the next release to get this feature. But as Gradle's build by convention behavior is build upon a general purpose build DSL there is a work around.

compile.actions[0] = {    ant {        mkdir(dir: classesDir)        javac(includeAntRuntime: false,                srcdir: srcDirs.join(':'),                destdir: classesDir,                classpath: dependencies.antpath('compile'),                target: targetCompatibility,                source: sourceCompatibility,                includes: 'org/gradle/webapp1/')    }}

Apple Mail does not handle new lines properly when I paste code snippets from Eclipse or IntelliJ. Pasting it first to TextEdit is at least a solution. Here a readable version:

compile.actions[0] = {
    ant {
        mkdir(dir: classesDir)
        javac(includeAntRuntime: false,
                srcdir: srcDirs.join(':'),
                destdir: classesDir,
                classpath: dependencies.antpath('compile'),
                target: targetCompatibility,
                source: sourceCompatibility,
                includes: 'org/gradle/webapp1/')
    }
}

- Hans


This replaces the build in compile behavior with something that solves your problem. We simply use the javac ant task and feed it with the project properties. Additionally we use javac's includes property to filter packages or whatever we want to filter. There is also an excludes property available.
We are not saying this is very convenient but not less convenient compared to an ant build. 
I have filed an issue for this: http://jira.codehaus.org/browse/GRADLE-89
This is going to be fixed in the next release.
- Hans


Thanks,
Chris....
-- 
Sent from the gradle-user mailing list archive at Nabble.com.


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




--
Hans Dockter
Gradle Project lead





--
Hans Dockter
Gradle Project lead




Reply | Threaded
Open this post in threaded view
|

Re: Compile Inculde/Exclude

chrishane@gmail.com
Thanks!  That is exactly what I need.

I really like what I see so far (6 hours trying to convert our old build system) with gradle and look forward to using it.  Gradle is actually (once I get what you suggested below working) a very easy tool to use.  Replacing our current custom build process (very complex ant scripts) with gradle is going to give us a much more manageable/repeatable process.  We've been wanting to migrate to Ivy for a while now; but have dreaded having to retrofit a lot of our build scripts to use ivy.  Gradle came along at the right time and we are making a clean break and redoing our build process.

Chris....

hdockter wrote
On May 11, 2008, at 8:50 AM, Hans Dockter wrote:

> Hi Chris,
>
> On May 10, 2008, at 12:49 AM, chrishane wrote:
>>
>> Is it possible to have an includes/excludes directive on the  
>> compile task?
>>
>> I am building a java project and our current build scripts compile  
>> specific
>> directories for specific build targets.  Until I can refactor the  
>> directory
>> structure, I need to compile only certain directories.
>
> I have been surprised myself when I discovered that the Gradle  
> Compile task does not offer this.
>
> On the other hand it is a good showcase that Gradle doesn't lock  
> you in. If Gradle where just a big framework you might had to wait  
> for the next release to get this feature. But as Gradle's build by  
> convention behavior is build upon a general purpose build DSL there  
> is a work around.
>
> compile.actions[0] = {    ant {        mkdir(dir:  
> classesDir)        javac(includeAntRuntime: false,                
> srcdir: srcDirs.join(':'),                destdir:  
> classesDir,                classpath: dependencies.antpath
> ('compile'),                target:  
> targetCompatibility,                source:  
> sourceCompatibility,                includes: 'org/gradle/
> webapp1/')    }}

Apple Mail does not handle new lines properly when I paste code  
snippets from Eclipse or IntelliJ. Pasting it first to TextEdit is at  
least a solution. Here a readable version:

compile.actions[0] = {
     ant {
         mkdir(dir: classesDir)
         javac(includeAntRuntime: false,
                 srcdir: srcDirs.join(':'),
                 destdir: classesDir,
                 classpath: dependencies.antpath('compile'),
                 target: targetCompatibility,
                 source: sourceCompatibility,
                 includes: 'org/gradle/webapp1/')
     }
}

- Hans

>
> This replaces the build in compile behavior with something that  
> solves your problem. We simply use the javac ant task and feed it  
> with the project properties. Additionally we use javac's includes  
> property to filter packages or whatever we want to filter. There is  
> also an excludes property available.
> We are not saying this is very convenient but not less convenient  
> compared to an ant build.
> I have filed an issue for this: http://jira.codehaus.org/browse/ 
> GRADLE-89
> This is going to be fixed in the next release.
> - Hans
>
>>
>> Thanks,
>> Chris....
>> --
>> View this message in context: http://www.nabble.com/Compile- 
>> Inculde-Exclude-tp17157729p17157729.html
>> Sent from the gradle-user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
> --
> Hans Dockter
> Gradle Project lead
> http://www.gradle.org
>
>
>
>

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



Reply | Threaded
Open this post in threaded view
|

Re: Compile Inculde/Exclude

hans_d
Administrator
Hi Chris,

with Gradle 0.2 you can now simply write:

usePlugin('java')
compile {
    include('org.mypackage1/', 'org.mypackage2/')
    exclude('org.mypackage2/I*.java/')
}

The patterns you can pass to the include/exclude method are Ant  
patterns.

- Hans

On May 12, 2008, at 5:05 PM, chrishane wrote:

>
> Thanks!  That is exactly what I need.
>
> I really like what I see so far (6 hours trying to convert our old  
> build
> system) with gradle and look forward to using it.  Gradle is  
> actually (once
> I get what you suggested below working) a very easy tool to use.  
> Replacing
> our current custom build process (very complex ant scripts) with  
> gradle is
> going to give us a much more manageable/repeatable process.  We've  
> been
> wanting to migrate to Ivy for a while now; but have dreaded having to
> retrofit a lot of our build scripts to use ivy.  Gradle came along  
> at the
> right time and we are making a clean break and redoing our build  
> process.
>
> Chris....
>
>
> hdockter wrote:
>>
>>
>> On May 11, 2008, at 8:50 AM, Hans Dockter wrote:
>>
>>> Hi Chris,
>>>
>>> On May 10, 2008, at 12:49 AM, chrishane wrote:
>>>>
>>>> Is it possible to have an includes/excludes directive on the
>>>> compile task?
>>>>
>>>> I am building a java project and our current build scripts compile
>>>> specific
>>>> directories for specific build targets.  Until I can refactor the
>>>> directory
>>>> structure, I need to compile only certain directories.
>>>
>>> I have been surprised myself when I discovered that the Gradle
>>> Compile task does not offer this.
>>>
>>> On the other hand it is a good showcase that Gradle doesn't lock
>>> you in. If Gradle where just a big framework you might had to wait
>>> for the next release to get this feature. But as Gradle's build by
>>> convention behavior is build upon a general purpose build DSL there
>>> is a work around.
>>>
>>> compile.actions[0] = {    ant {        mkdir(dir:
>>> classesDir)        javac(includeAntRuntime: false,
>>> srcdir: srcDirs.join(':'),                destdir:
>>> classesDir,                classpath: dependencies.antpath
>>> ('compile'),                target:
>>> targetCompatibility,                source:
>>> sourceCompatibility,                includes: 'org/gradle/
>>> webapp1/')    }}
>>
>> Apple Mail does not handle new lines properly when I paste code
>> snippets from Eclipse or IntelliJ. Pasting it first to TextEdit is at
>> least a solution. Here a readable version:
>>
>> compile.actions[0] = {
>>      ant {
>>          mkdir(dir: classesDir)
>>          javac(includeAntRuntime: false,
>>                  srcdir: srcDirs.join(':'),
>>                  destdir: classesDir,
>>                  classpath: dependencies.antpath('compile'),
>>                  target: targetCompatibility,
>>                  source: sourceCompatibility,
>>                  includes: 'org/gradle/webapp1/')
>>      }
>> }
>>
>> - Hans
>>
>>>
>>> This replaces the build in compile behavior with something that
>>> solves your problem. We simply use the javac ant task and feed it
>>> with the project properties. Additionally we use javac's includes
>>> property to filter packages or whatever we want to filter. There is
>>> also an excludes property available.
>>> We are not saying this is very convenient but not less convenient
>>> compared to an ant build.
>>> I have filed an issue for this: http://jira.codehaus.org/browse/
>>> GRADLE-89
>>> This is going to be fixed in the next release.
>>> - Hans
>>>
>>>>
>>>> Thanks,
>>>> Chris....
>>>> --
>>>> View this message in context: http://www.nabble.com/Compile-
>>>> Inculde-Exclude-tp17157729p17157729.html
>>>> Sent from the gradle-user mailing list archive at Nabble.com.
>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>
>>> --
>>> Hans Dockter
>>> Gradle Project lead
>>> http://www.gradle.org
>>>
>>>
>>>
>>>
>>
>> --
>> Hans Dockter
>> Gradle Project lead
>> http://www.gradle.org
>>
>>
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Compile-Inculde- 
> Exclude-tp17157729p17189439.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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 | Threaded
Open this post in threaded view
|

Re: Compile Inculde/Exclude

chrishane@gmail.com

Hans - thanks for the update.  I plan on revisiting our build system before the end of the month and look forward to using gradle.  It looks like it is coming along nicely.

Chris....

hdockter wrote
Hi Chris,

with Gradle 0.2 you can now simply write:

usePlugin('java')
compile {
    include('org.mypackage1/', 'org.mypackage2/')
    exclude('org.mypackage2/I*.java/')
}

The patterns you can pass to the include/exclude method are Ant  
patterns.

- Hans