Statement ordering in Gradle file -- Probably a JIRA needed?

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

Statement ordering in Gradle file -- Probably a JIRA needed?

Russel Winder-2
With the Gradle script:

        ant.property ( file : 'build.properties' )
        type = 'jar'
        group = 'org.codehaus.gant'
        version = ant.antProject.properties.gantVersion
        usePlugin ( 'groovy' )
        dependencies {
          addMavenRepo ( "file://${ System.properties.'user.home' }/.m2/repository" )
          groovy ( 'org.codehaus.groovy:groovy-all:1.6-beta-2-SNAPSHOT' )
          compile ( 'commons-cli:commons-cli:' + ant.antProject.properties.commonsCliVersion )
          testCompile ( 'junit:junit:' + ant.antProject.properties.junitVersion )
        }
        sourceCompatibility = 1.5
        targetCompatibility = 1.5
       
then compilation succeeds (but the tests fail, that is another issue
though).

If however, I move the compatibility specifications above the usePlugin
specification then I get a javac invocation failure:

        org.gradle.api.GradleScriptException: Build file '/home/users/russel/Repositories/Git/Master/Gant/build.gradle'
        Execution failed for task :compile.
        at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:193)
        at org.gradle.execution.BuildExecuter.execute(BuildExecuter.java:127)
        at org.gradle.execution.BuildExecuter.execute(BuildExecuter.java:68)
        at org.gradle.execution.BuildExecuter.execute(BuildExecuter.java:78)
        at org.gradle.execution.NameResolvingTaskExecuter.execute(NameResolvingTaskExecuter.java:104)
        at org.gradle.Gradle.runInternal(Gradle.java:162)
        at org.gradle.Gradle.run(Gradle.java:123)
        at org.gradle.Main.main(Main.java:234)
        at org.gradle.BootstrapMain.main(BootstrapMain.java:53)
        Caused by: org.apache.tools.ant.BuildException: Compilation Failed
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at Script1.run(Script1.groovy:5)
        at org.gradle.util.GradleUtil.executeIsolatedAntScript(GradleUtil.groovy:94)
        at org.gradle.api.tasks.compile.AntGroovyc.execute(AntGroovyc.groovy:54)
        at org.gradle.api.tasks.compile.GroovyCompile.compile(GroovyCompile.java:97)
        at org.gradle.api.tasks.compile.GroovyCompile$1.execute(GroovyCompile.java:70)
        at org.gradle.api.internal.AbstractTask.doExecute(AbstractTask.java:203)
        at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:185)
        ... 8 common frames omitted
        Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Invalid commandline usage for javac.
        javac: invalid source release: null
        Usage: javac <options> <source files>
        use -help for a list of possible options

I guess there is an ordering or default problem here?



--
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Statement ordering in Gradle file -- Probably a JIRA needed?

hans_d
Administrator
Hi Russel,

On Oct 6, 2008, at 10:44 AM, Russel Winder wrote:

> With the Gradle script:
>
>         ant.property ( file : 'build.properties' )
>         type = 'jar'
>         group = 'org.codehaus.gant'
>         version = ant.antProject.properties.gantVersion
>         usePlugin ( 'groovy' )
>         dependencies {
>           addMavenRepo ( "file://$
> { System.properties.'user.home' }/.m2/repository" )
>           groovy ( 'org.codehaus.groovy:groovy-all:1.6-beta-2-
> SNAPSHOT' )
>           compile ( 'commons-cli:commons-cli:' +  
> ant.antProject.properties.commonsCliVersion )
>           testCompile ( 'junit:junit:' +  
> ant.antProject.properties.junitVersion )
>         }
>         sourceCompatibility = 1.5
>         targetCompatibility = 1.5
>
> then compilation succeeds (but the tests fail, that is another issue
> though).
>
> If however, I move the compatibility specifications above the  
> usePlugin
> specification then I get a javac invocation failure:

this is expected but unintuitive behavior. We want to introduce name  
spaces very soon. You then would write:

usePlugin('java')
java.sourceCompatibility = 1.5
...

Then it would be clearer that you first have to introduce the  
namespace before you can assign something to it.

- Hans

--
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: Statement ordering in Gradle file -- Probably a JIRA needed?

Adam Murdoch-2


Hans Dockter wrote:

> Hi Russel,
>
> On Oct 6, 2008, at 10:44 AM, Russel Winder wrote:
>
>> With the Gradle script:
>>
>>         ant.property ( file : 'build.properties' )
>>         type = 'jar'
>>         group = 'org.codehaus.gant'
>>         version = ant.antProject.properties.gantVersion
>>         usePlugin ( 'groovy' )
>>         dependencies {
>>           addMavenRepo ( "file://${ System.properties.'user.home'
>> }/.m2/repository" )
>>           groovy (
>> 'org.codehaus.groovy:groovy-all:1.6-beta-2-SNAPSHOT' )
>>           compile ( 'commons-cli:commons-cli:' +
>> ant.antProject.properties.commonsCliVersion )
>>           testCompile ( 'junit:junit:' +
>> ant.antProject.properties.junitVersion )
>>         }
>>         sourceCompatibility = 1.5
>>         targetCompatibility = 1.5
>>
>> then compilation succeeds (but the tests fail, that is another issue
>> though).
>>
>> If however, I move the compatibility specifications above the usePlugin
>> specification then I get a javac invocation failure:
>
> this is expected but unintuitive behavior. We want to introduce name
> spaces very soon. You then would write:
>
> usePlugin('java')
> java.sourceCompatibility = 1.5
> ...
>
> Then it would be clearer that you first have to introduce the
> namespace before you can assign something to it.
>

Possibly. Another approach - not necessarily incompatible with
namespaces - might be to apply a project's additional properties to a
plugin convention object when the convention object is added. This would
also allow the convention properties to be overridden from the command-line.


Adam

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Statement ordering in Gradle file -- Probably a JIRA needed?

hans_d
Administrator

On Oct 6, 2008, at 11:06 PM, Adam Murdoch wrote:

>
>
> Hans Dockter wrote:
>> Hi Russel,
>>
>> On Oct 6, 2008, at 10:44 AM, Russel Winder wrote:
>>
>>> With the Gradle script:
>>>
>>>         ant.property ( file : 'build.properties' )
>>>         type = 'jar'
>>>         group = 'org.codehaus.gant'
>>>         version = ant.antProject.properties.gantVersion
>>>         usePlugin ( 'groovy' )
>>>         dependencies {
>>>           addMavenRepo ( "file://$
>>> { System.properties.'user.home' }/.m2/repository" )
>>>           groovy ( 'org.codehaus.groovy:groovy-all:1.6-beta-2-
>>> SNAPSHOT' )
>>>           compile ( 'commons-cli:commons-cli:' +  
>>> ant.antProject.properties.commonsCliVersion )
>>>           testCompile ( 'junit:junit:' +  
>>> ant.antProject.properties.junitVersion )
>>>         }
>>>         sourceCompatibility = 1.5
>>>         targetCompatibility = 1.5
>>>
>>> then compilation succeeds (but the tests fail, that is another issue
>>> though).
>>>
>>> If however, I move the compatibility specifications above the  
>>> usePlugin
>>> specification then I get a javac invocation failure:
>>
>> this is expected but unintuitive behavior. We want to introduce  
>> name spaces very soon. You then would write:
>>
>> usePlugin('java')
>> java.sourceCompatibility = 1.5
>> ...
>>
>> Then it would be clearer that you first have to introduce the  
>> namespace before you can assign something to it.
>>
>
> Possibly. Another approach - not necessarily incompatible with  
> namespaces - might be to apply a project's additional properties to  
> a plugin convention object when the convention object is added.  
> This would also allow the convention properties to be overridden  
> from the command-line.

Good idea.

Sidetopic: Are you in favor of namespaces for plugins?

- Hans

--
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: Statement ordering in Gradle file -- Probably a JIRA needed?

Adam Murdoch-2


Hans Dockter wrote:

>
> On Oct 6, 2008, at 11:06 PM, Adam Murdoch wrote:
>
>>
>>
>> Hans Dockter wrote:
>>> Hi Russel,
>>>
>>> On Oct 6, 2008, at 10:44 AM, Russel Winder wrote:
>>>
>>>> With the Gradle script:
>>>>
>>>>         ant.property ( file : 'build.properties' )
>>>>         type = 'jar'
>>>>         group = 'org.codehaus.gant'
>>>>         version = ant.antProject.properties.gantVersion
>>>>         usePlugin ( 'groovy' )
>>>>         dependencies {
>>>>           addMavenRepo ( "file://${ System.properties.'user.home'
>>>> }/.m2/repository" )
>>>>           groovy (
>>>> 'org.codehaus.groovy:groovy-all:1.6-beta-2-SNAPSHOT' )
>>>>           compile ( 'commons-cli:commons-cli:' +
>>>> ant.antProject.properties.commonsCliVersion )
>>>>           testCompile ( 'junit:junit:' +
>>>> ant.antProject.properties.junitVersion )
>>>>         }
>>>>         sourceCompatibility = 1.5
>>>>         targetCompatibility = 1.5
>>>>
>>>> then compilation succeeds (but the tests fail, that is another issue
>>>> though).
>>>>
>>>> If however, I move the compatibility specifications above the
>>>> usePlugin
>>>> specification then I get a javac invocation failure:
>>>
>>> this is expected but unintuitive behavior. We want to introduce name
>>> spaces very soon. You then would write:
>>>
>>> usePlugin('java')
>>> java.sourceCompatibility = 1.5
>>> ...
>>>
>>> Then it would be clearer that you first have to introduce the
>>> namespace before you can assign something to it.
>>>
>>
>> Possibly. Another approach - not necessarily incompatible with
>> namespaces - might be to apply a project's additional properties to a
>> plugin convention object when the convention object is added. This
>> would also allow the convention properties to be overridden from the
>> command-line.
>
> Good idea.
>
> Sidetopic: Are you in favor of namespaces for plugins?
>

I'm not fussed. I've found myself doing this for my own plugins, so its
probably a useful thing.

As far as behaviour goes, would we change the property resolution on
DefaultProject, so that for property p
1. look for property p on the project object itself
2. look for an additional property with name p
3. look for property p on each of the plugin convention objects
4. look a plugin convention object with name p (the new step)
5. look for a task with name p
6. look for a property p on the parent project

Perhaps 3 and 4 should be swapped.

Unrelated, but I wonder if there should be a step between 5 and 6 where
we look for a subproject with name p?


Adam


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

    http://xircles.codehaus.org/manage_email