0

I have a gradle project titled 'FunctionalityMaintainer' I am trying to execute two JavaExec tasks in a build.gradle, but independantly. The following is the structure of my build.gradle

task(findPattern, dependsOn:'classes', type:JavaExec){
main = 'org.package.somepackage1.PatternMatcher'
classpath = sourceSets.main.runtimeClasspath
args = [project.getProperty('baseDir'), project.getProperty('playGroundWorkspace')]
}

task(deleteZip, dependsOn:'classes', type:JavaExec){
main = 'org.package.somepackage2.ZipDeleter'
classpath = sourceSets.main.runtimeClasspath
args = [project.getProperty('zipPath')]
}

If I execute say deleteZip task, with the following command -

gradle deleteZip -PzipPath='D:/PathtoZip'

It fails with the error,

could not get unknown property 'baseDir' for root project 'FunctionalityMaintainer' of type org.gradle.api.Project. 

Can somebody please tell me what am I doing wrong?

user2179627
  • 367
  • 1
  • 4
  • 15
  • 1
    When using `project.getProperty()` Gradle will throw `MissingPropertyException` if the property is not found (in your case you don't provide value for `basedir` and `playGroundWorkspace`, that's why the build fails) You should rather use `project.findProperty()` method if you have some optional properties in your script, or initialize these properties with default values. – M.Ricciuti Jan 22 '19 at 09:06
  • yes, you are right. Thank you so much. :) I gave default values to all the properties and now it's working – user2179627 Jan 22 '19 at 13:00

0 Answers0