我正在创建一个应用程序,它基本上由3个JAVA模块组成:
因此AndroidApp和HTTPServerStandalone之间没有依赖关系。他们并不需要彼此。
现在我遇到了一个问题,因为我没有安装Android SDK就无法构建HTTPServerStandalone,因为settings.gradle包含所有3个模块的include。有没有办法,在构建HTTPServerStandalone时如何防止包含AndroidApp?
答案 0 :(得分:0)
是的,可以 - settings.gradle:
def localProperties = new File("$rootDir", "local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir != null) {
def folder = new File(sdkDir);
if (folder.isDirectory()) {
include ':AndroidApp';
} else {
println "WARINING: SKIPPING :AndroidApp MISSING '" + sdkDir + "' IS NOT A DIRECTORY";
}
} else {
println "WARINING: SKIPPING :AndroidApp MISSING 'sdk.dir' IN FILE $rootDir/local.properties";
}
} else {
println "WARINING: SKIPPING :AndroidApp MISSING FILE $rootDir/local.properties";
}
include ':HTTPServerStandalone', ':HTTPServer'
您知道更好的解决方案吗?