Problem calling a task with arguments (using -P), getting groovy.lang.MissingPropertyException


(geirsande) #1

I have a following task (aka trying to call ‘cleanEclipse’ and ‘eclipse’ on a specific project):

task buildEclipseSettingsFor(type: GradleBuild) { GradleBuild task ->

group = ‘IDE’

description = ‘Build fresh Eclipse settings for a specific module.’

def settingsFor = task.project.property(‘settingsFor’)

def cleanEclipse = “${settingsFor}:cleanEclipse”

def eclipse = “${settingsFor}:eclipse”

tasks << cleanEclipse

tasks << eclipse

doLast { println “Eclipse settings ready for ${settingsFor}. Now import the project (without copying it) into Eclipse.” } }

if I run the task ‘gradle --stacktrace -PsettingsFor=perftence buildEclipseSettingsFor’

I will get:

Caused by: groovy.lang.MissingPropertyException: Could not find property ‘settingsFor’ on root project ‘svn’.

at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)

at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)

at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:94)

at org.gradle.api.internal.project.AbstractProject.property(AbstractProject.java:787)

at org.gradle.api.Project$property.call(Unknown Source)


(Peter Niederwieser) #2

Which line in the build script throws the exception? Could you please repost and format the text as code?


(geirsande) #3

Exception is thrown at

def settingsFor = task.project.property('settingsFor')

Here’s the code:

task buildEclipseSettingsFor(type: GradleBuild)
{ GradleBuild task ->
    group = 'IDE'
    description = 'Build Eclipse settings for a specific module.'
    def settingsFor = task.project.property('settingsFor')
    def cleanEclipse = "${settingsFor}:cleanEclipse"
    def eclipse = "${settingsFor}:eclipse"
    tasks << cleanEclipse
    tasks << eclipse
    doLast { println "Eclipse settings ready for ${settingsFor}. Now import the project (without copying it) into Eclipse." }
}

(Luke Daley) #4

The most important information from the stack trace (i.e. which line the exception is being thrown from) is not show in your stack trace.

Please post the full stack trace.


(geirsande) #5
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'svn'.
 at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
 at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
 at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
 at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
 at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:463)
 at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:75)
 at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
 at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
 at org.gradle.api.internal.Actions$CompositeAction.execute(Actions.java:67)
 at org.gradle.api.internal.Actions$TransformingActionAdapter.execute(Actions.java:96)
 at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:439)
 at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:434)
 at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:32)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
 at org.gradle.api.tasks.GradleBuild.build(GradleBuild.java:112)
 at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
 at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
 at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
 at org.gradle.api.tasks.GradleBuild_Decorated.invokeMethod(Unknown Source)
 at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
 at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$4.execute(AnnotationProcessingTaskFactory.java:161)
 at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$4.execute(AnnotationProcessingTaskFactory.java:156)
 at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:472)
 at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:461)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:60)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
 at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)
 at org.gradle.api.internal.changedetection.CacheLockHandlingTaskExecuter$1.run(CacheLockHandlingTaskExecuter.java:34)
 at org.gradle.internal.Factories$1.create(Factories.java:22)
 at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:179)
 at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:232)
 at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:138)
 at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:83)
 at org.gradle.api.internal.changedetection.CacheLockHandlingTaskExecuter.execute(CacheLockHandlingTaskExecuter.java:32)
 at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)
 at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
 at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
 at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
 at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
 at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
 at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:247)
 at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.executeTask(DefaultTaskPlanExecutor.java:52)
 at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.processTask(DefaultTaskPlanExecutor.java:38)
 at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:30)
 at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)
 at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
 at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
 at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
 at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
 at org.gradle.internal.Factories$1.create(Factories.java:22)
 at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
 at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
 at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:130)
 at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
 at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
 at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
 at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
 at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:158)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
 at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38)
 at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
 at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:25)
 at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
 at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:137)
 at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
 at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
 at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
 at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
 at org.gradle.launcher.Main.doAction(Main.java:48)
 at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
 at org.gradle.launcher.Main.main(Main.java:39)
 at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
 at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
 at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: groovy.lang.MissingPropertyException: Could not find property 'settingsFor' on root project 'svn'.
 at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
 at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
 at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:94)
 at org.gradle.api.internal.project.AbstractProject.property(AbstractProject.java:787)
 at org.gradle.api.Project$property.call(Unknown Source)
 at build_4mqv9f8s1lcneotrfo4vg7d84m$_run_closure4.doCall(/home/gesande/work/perftence/svn/build.gradle:90)
 at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
 at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
 at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:110)
 at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:387)
 at org.gradle.api.internal.project.AbstractProject.task(AbstractProject.java:916)
 at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
 at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
 at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
 at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83)
 at build_4mqv9f8s1lcneotrfo4vg7d84m.run(/home/gesande/work/perftence/svn/build.gradle:87)
 at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
 ... 83 more

(geirsande) #6

build.gradle:90 would be the

def settingsFor = task.project.property('settingsFor')

build.gradle:87 would be the

task buildEclipseSettingsFor(type: GradleBuild)
{ GradleBuild task ->

(Luke Daley) #7

I’m a bit stumped on this. There’s some kind of variable here that’s hidden, at least to me.

Any chance you could put together a small sample that I can run that has this problem? If I simply copy/paste your example above and create a sample from it it works fine for me.


(geirsande) #8

build.gradle

apply plugin: 'eclipse'
apply plugin: 'java'
  subprojects {
}
  task buildEclipseSettingsFor(type: GradleBuild)
{ GradleBuild task ->
    group = 'IDE'
    description = 'Build fresh Eclipse settings for a specific module.'
    def settingsFor = task.project.property('settingsFor')
    def cleanEclipse = "${settingsFor}:cleanEclipse"
    def eclipse = "${settingsFor}:eclipse"
    tasks << cleanEclipse
    tasks << eclipse
    doLast { println "Eclipse settings ready for ${settingsFor}. Now import the project (without copying it) into Eclipse." }
}
    project(':project1'){}
  project(':project2') {}

settings.gradle

include 'project1','project2'

gradle -version

------------------------------------------------------------ Gradle 1.3 ------------------------------------------------------------

Gradle build time: Tuesday, November 20, 2012 11:37:38 AM UTC Groovy: 1.8.6 Ant: Apache Ant™ version 1.8.4 compiled on May 22 2012 Ivy: 2.2.0 JVM: 1.6.0_35 (Sun Microsystems Inc. 20.10-b01) OS: Linux 2.6.32-45-generic amd64


(Luke Daley) #9

Looks like a strange bug with the property() method. This version works:

task buildEclipseSettingsFor(type: GradleBuild) { GradleBuild task ->
  group = 'IDE'
  description = 'Build fresh Eclipse settings for a specific module.'
  def settingsFor = project.properties.settingsFor
 String cleanEclipse = "${settingsFor}:cleanEclipse"
  String eclipse = "${settingsFor}:eclipse"
  tasks << cleanEclipse
  tasks << eclipse
  doLast { println "Eclipse settings ready for ${settingsFor}. Now import the project (without copying it) into Eclipse." }
 }

(geirsande) #10

Thanks, that worked.