in src/com/intellij/idea/plugin/hybris/project/compile/ProjectBeforeCompilerTask.kt [57:104]
override fun execute(context: CompileContext): Boolean {
val settings = ProjectSettingsComponent.getInstance(context.project)
if (!settings.isHybrisProject()) return true
if (!settings.state.generateCodeOnRebuild) {
context.addMessage(CompilerMessageCategory.WARNING, "[y] Code generation is disabled, to enable it adjust SAP Commerce Project specific settings.", null, -1, -1)
return true
}
val typeId = context.compileScope.getUserData(CompilerManager.RUN_CONFIGURATION_TYPE_ID_KEY)
// do not rebuild sources in case of JUnit
// see JUnitConfigurationType
if ("JUnit" == typeId && !settings.state.generateCodeOnJUnitRunConfiguration) return true
val modules = context.compileScope.affectedModules
val platformModule = modules.firstOrNull { it.yExtensionName() == HybrisConstants.EXTENSION_NAME_PLATFORM }
?: return true
val platformModuleRoot = platformModule.root()
?: return true
val coreModuleRoot = modules
.firstOrNull { it.yExtensionName() == HybrisConstants.EXTENSION_NAME_CORE }
?.root()
?: return true
val sdk = ModuleRootManager.getInstance(platformModule).sdk
?: return true
val sdkVersion = JavaSdk.getInstance().getVersion(sdk)
?: return true
val vmExecutablePath = (sdk.sdkType as? JavaSdkType)
?.getVMExecutablePath(sdk)
?: return true
val bootstrapDirectory = platformModuleRoot.resolve(HybrisConstants.PLATFORM_BOOTSTRAP_DIRECTORY)
if (!invokeCodeGeneration(context, platformModuleRoot, bootstrapDirectory, coreModuleRoot, vmExecutablePath, settings.state)) {
ProjectCompileUtil.triggerRefreshGeneratedFiles(bootstrapDirectory)
return false
}
if (!invokeCodeCompilation(context, platformModule, bootstrapDirectory, sdkVersion)) {
ProjectCompileUtil.triggerRefreshGeneratedFiles(bootstrapDirectory)
return false
}
if (!invokeModelsJarCreation(context, bootstrapDirectory)) {
ProjectCompileUtil.triggerRefreshGeneratedFiles(bootstrapDirectory)
return false
}
return true;
}