I want to pass a parameter to the gradle script from the command line.
Our project has a dependency to a local jar that could be in different locations depending on the machine it runs. So I want to pass part of the path as a command line argument with -Ptranscad= so it’s machine specific. The jar can not be placed in a central location for all to access due to licensing issues.
I am able to do this with no problems from the command line but I am having problems with the Buildship plugin in eclipse.
this
dependencies {
compileOnly files(project.transcad+‘/GISDK/Matrices/TranscadMatrix.jar’)
}
works perfect from the command line but produces the following error on Eclipse and the project in the gradle tasks view is marked with a red X indicating an error
Could not get unknown property ‘transcad’ for project ‘:ctramp21’ of type org.gradle.api.Project.
I have to do the following work around to get it to work on eclipse
def transcad_path = project.hasProperty(‘transcad’) ? project.transcad : ‘C:/TransCAD_6’
dependencies {
compileOnly files(transcad_path+‘/GISDK/Matrices/TranscadMatrix.jar’)
}
This of course is an issue because we have a hardcoded path that could change from machine to machine. For example, when we do a gradle->refresh gradle project on a machine where the jar is on a different location we get compilation errors since it can’t find the jar to add it to the classpath.
Another problem is that Buildship runs some sort of Configuration check on the gradle projects when eclipse starts up or if you refresh the gradle tasks view, and there is nowhere to pass a command line parameter for that step. Unless there is and I have missed it. Does anyone know how to do this? This not when you run a specific task. I know how to set up the run configuration for specific tasks.