Archived
0

gradle: передача System properties в запускаемый процесс

This commit is contained in:
2019-01-29 13:06:45 +03:00
parent 23f2b689fe
commit e7516edc57

View File

@@ -139,9 +139,6 @@ subprojects {
* -DworkDir=path\to\workdir
* Если используется отдельная папка для имплементации логгера, то указываем
* -DlogImplDir=path\to\logimpldir
* Если необходимо передать дополнительные JVM параметры серверу, то указываем их с двойной "D", например:
* -DDspringConfig=spring.xml
* -DDlog4j.configurationFile=log4j2.xml
*/
task runServer(type: JavaExec) {
main = 'mc.core.Main'
@@ -153,14 +150,19 @@ task runServer(type: JavaExec) {
}
if (System.getProperty("logImplDir") != null) {
classpath += files(fileTree(dir: new File(System.getProperty("logImplDir"))))
def logImplDir = new File(System.getProperty("logImplDir"))
if (logImplDir.isAbsolute()) {
classpath += files(fileTree(dir: logImplDir))
} else {
classpath += files(fileTree(dir: new File(workingDir, logImplDir.getPath())))
}
} else {
classpath += files(fileTree(dir: new File(workingDir, "log-impl")))
}
System.getProperties().stringPropertyNames().stream()
.filter{propName -> propName.startsWith("D")}
.forEach{propName -> jvmArgs += "-D" + propName.substring(1) + "=" + System.getProperty(propName)}
systemProperties System.properties
systemProperties.put("user.dir", workingDir)
ignoreExitValue = true
}