build scripts: report an error if proper JRE cannot be bundled when running build on TeamCity

Previously the script will just report a warning, so we can get a successful build with missing artifacts. New 'Development mode' option is added for such cases.
This commit is contained in:
nik
2017-03-31 17:09:46 +03:00
parent dd58bac2c2
commit 9ab44673cf
2 changed files with 24 additions and 4 deletions
@@ -93,4 +93,12 @@ class BuildOptions {
* change the output directory.
*/
String outputRootPath = System.getProperty("intellij.build.output.root")
/**
* If {@code true} the build is running in 'Development mode' i.e. its artifacts aren't supposed to be used in production. In development
* mode build scripts won't fail if some non-mandatory dependencies are missing and will just show warnings.
* <p>By default 'development mode' is enabled if build is not running under continuous integration server (TeamCity).</p>
*/
boolean isInDevelopmentMode = SystemProperties.getBooleanProperty("intellij.build.dev.mode",
System.getProperty("teamcity.buildType.id") == null)
}
@@ -122,12 +122,24 @@ class BundledJreManager {
String suffix = arch == JvmArchitecture.x32 ? "_x86" : "_x64"
String prefix = buildContext.productProperties.toolsJarRequired ? vendor.jreWithToolsJarNamePrefix : vendor.jreNamePrefix
Collection<File> jdkFiles = jdkDir.listFiles()?.findAll { it.name.startsWith(prefix) && it.name.endsWith("${suffix}.tar.gz") } ?: [] as List<File>
String errorMessage;
if (jdkFiles.size() > 1) {
buildContext.messages.warning("Cannot extract $osDirName JRE: several matching files are found ($jdkFiles)")
return null
errorMessage = "Cannot extract $osDirName JRE: several matching files are found ($jdkFiles)"
}
if (jdkFiles.isEmpty()) {
buildContext.messages.warning("Cannot extract $osDirName JRE: no '${prefix}...${suffix}.tar.gz' files found in $jdkDir")
else if (jdkFiles.isEmpty()) {
errorMessage = "Cannot extract $osDirName JRE: no '${prefix}...${suffix}.tar.gz' files found in $jdkDir"
}
else {
errorMessage = null
}
if (errorMessage != null) {
if (buildContext.options.isInDevelopmentMode) {
buildContext.messages.warning(errorMessage)
}
else {
buildContext.messages.error(errorMessage)
}
return null
}
return jdkFiles.first()