So, I am a bit new to Gradle. I have a build file that I have been trying to debug for hours now. I am executing it through eclipse’s Run Configurations to pass in command-line parameters. This is it:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'application'
repositories {
maven {
url "https://maven..com/artifactory/libs-release"
}
flatDir {
dirs 'libs'
}
}
sourceCompatibility = 1.8
version = "1.0.0-SNAPSHOT"
dependencies {
runtime fileTree("../BidirectionalDetector/build/libs")
compile name: 'soot-3.0.0-jar-with-dependencies'
compile name: 'plantuml-6703'
compile name: 'SignatureEvaluator-1.0.9'
compile 'org.apache.logging.log4j:log4j-api:2.+'
compile 'org.apache.logging.log4j:log4j-core:2.+'
testCompile 'junit:junit:4.+'
testCompile "org.mockito:mockito-core:2.+"
}
compileJava {
options.compilerArgs << '-g'
}
mainClassName = "csse374.infamousyams.main.Main"
applicationDefaultJvmArgs = ["-Xms512m", "-Xmx1024m"]
run {
standardInput = System.in
println "has property: " + project.hasProperty("args")
println "has property: " + project.hasProperty("appArgs")
if ( project.hasProperty("appArgs") ) {
String passed = project.getProperty("appArgs");
List<String> toReturn = new ArrayList<>();
java.util.regex.Pattern p = java.util.regex.Pattern.compile("(?:([^\\s^\"]+)|(\"[^\"]*\"))");
java.util.regex.Matcher m = p.matcher(passed);
while(m.find()) {
toReturn.add(m.group());
}
args toReturn.toArray()
println args
}
}
task myRun(type: JavaExec, dependsOn: run) {
doLast {
println args
println "has property: " + project.hasProperty("args")
}
}
jar {
manifest {
attributes 'Implementation-Title': '374UMLDesigner',
'Implementation-Version': '${version}'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.3.1'
}
I am trying to add properties from the command-line using -Pappprop=“some string for a property”.
I tried multiple solutions online, but none seem to work. Am I doing something wrong?
This is the output I get:
has property: false
has property: false
FAILURE: Build failed with an exception.
* What went wrong:
Problem configuring task :build from command line.
> Unknown command-line option '-P'.
These are the run configs I ran:
build -PappArgs=[....]
run-PappArgs=[....]
What am I doing that is causing this to happen?
Thanks!