On 16/09/2010, at 3:06 AM, Philip Crotwell wrote:
> I decided to edit my custom plugins using eclipse. Sequence is:
>
> cd buildSrc
> gradle eclipse
>
> FAILURE: Could not determine which tasks to execute.
>
> * What went wrong:
> Task 'eclipse' not found in root project 'buildSrc'.
>
> OK, so I create build.gradle and add "apply plugin: 'eclipse'
>
> * What went wrong:
> Failed to notify build listener.
> Cause: Could not find any convention object of type EmbeddableJavaProject.
>
> So then I add "apply plugin:'groovy'
>
> * What went wrong:
> Execution failed for task ':compileGroovy'.
> Cause: You must assign a Groovy library to the groovy configuration!
>
> So then I read the user manual and find you need to specify groovy
> version and library, so I add this to build.gradle:
> repositories {
> mavenCentral()
> }
> dependencies {
> groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.0'
> testCompile group: 'junit', name: 'junit', version: '4.7'
> }
>
> but then I got lots of messages like:
>
> 4x4:~/dev/seis/buildSrc crotwell$ gradle eclipse
> Download
> http://repo1.maven.org/maven2/org/codehaus/groovy/groovy/1.7.0/groovy-1.7.0.pom
> Download http://repo1.maven.org/maven2/jline/jline/0.9.94/jline-0.9.94.pom
> Download
> http://repo1.maven.org/maven2/org/codehaus/groovy/groovy/1.7.0/groovy-1.7.0.jar
> Download http://repo1.maven.org/maven2/jline/jline/0.9.94/jline-0.9.94.jar
> :buildSrc:compileJava
> :buildSrc:compileGroovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> /export/home/crotwell/dev/seis/buildSrc/src/main/groovy/CopyToLib.groovy:
> 3: unable to resolve class org.gradle.api.tasks.TaskAction
> @ line 3, column 1.
> import org.gradle.api.tasks.TaskAction
>
> So, then I realize that maybe runnig gradle inside buildSrc is picking
> up on the settings.gradle one directory up in my multiproject. Was
> starting to get weird errors like:
> * What went wrong:
> Could not load compiled classes for build file
> '/export/home/crotwell/dev/seis/buildSrc/build.gradle' from cache.
>
> So, then I did "gradle -C rebuild clean" and things seemed to be ok. I
> could then run "gradle -u eclipse" and it worked fine.
>
> But then, I went to one of my regular projects and did gradle
> compileJava and got this:
> :buildSrc:clean
> :buildSrc:compileJava UP-TO-DATE
> :buildSrc:compileGroovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> /home/crotwell/dev/seis/buildSrc/src/main/groovy/CopyToLib.groovy: 2:
> unable to resolve class org.gradle.api.DefaultTask
> @ line 2, column 1.
> import org.gradle.api.DefaultTask
> ^
>
> So, it appears that my putting a build.gradle into my buildSrc was a
> very, very bad idea!
>
> So, some questions:
>
> 1) What do you need to put into build.gradle in buildSrc in order for
> groovy files to compile like they do without a build.gradle?
This is the default build script that gets used for the buildSrc dir:
apply plugin: 'groovy'
dependencies {
compile gradleApi()
groovy localGroovy()
}
You can start with this. Perhaps Gradle should apply this script automatically
before executing whatever build script it finds in the buildSrc directory. That
way, you can just add stuff without needing to reimplement the above.
>
> 2) What should a user do to allow other plugins like eclipse to be
> used in buildSrc other than a build.gradle with apply plugin:
> 'eclipse' in buildSrc?
Nothing really. You could add some stuff to your init script.
There's a few things Gradle could do:
* We could add the eclipse and idea plugins to the default buildSrc build script
* Add eclipse and idea as 'built-in' tasks that are available to every project
* Change the eclipse plugin so that when you apply it to the root project, it
also generates the project files for the buildSrc project.
>
> 3) Should gradle know the difference between using a settings.gradle
> in a normal project sense and when inside buildSrc?
Probably.
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz