mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
build scripts: code which prints log message about created artifact moved to BuildMessageLogger and implemented properly for TeamCity
This commit is contained in:
@@ -156,6 +156,8 @@ interface BuildMessages {
|
||||
void progress(String message)
|
||||
public <V> V block(String blockName, Closure<V> body)
|
||||
|
||||
void artifactBuild(String relativeArtifactPath)
|
||||
|
||||
BuildMessages forkForParallelTask(String taskName)
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ import groovy.transform.Immutable
|
||||
@Immutable
|
||||
class LogMessage {
|
||||
enum Kind {
|
||||
ERROR, WARNING, INFO, PROGRESS, BLOCK_STARTED, BLOCK_FINISHED
|
||||
ERROR, WARNING, INFO, PROGRESS, BLOCK_STARTED, BLOCK_FINISHED, ARTIFACT_BUILT
|
||||
}
|
||||
final Kind kind
|
||||
final String text
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.intellij.build.impl
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import groovy.transform.CompileDynamic
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.intellij.build.*
|
||||
@@ -35,15 +34,13 @@ import org.jetbrains.jps.util.JpsPathUtil
|
||||
@CompileStatic
|
||||
class BuildContextImpl extends BuildContext {
|
||||
private final JpsGlobal global
|
||||
private final boolean underTeamCity
|
||||
final List<String> outputDirectoriesToKeep
|
||||
|
||||
//todo[nik] construct buildOutputRoot automatically based on product name
|
||||
static BuildContextImpl create(AntBuilder ant, JpsGantProjectBuilder projectBuilder, JpsProject project, JpsGlobal global,
|
||||
String communityHome, String projectHome, String buildOutputRoot, ProductProperties productProperties,
|
||||
BuildOptions options, MacHostProperties macHostProperties, SignTool signTool, ScrambleTool scrambleTool) {
|
||||
boolean underTeamCity = System.getProperty("teamcity.buildType.id") != null
|
||||
BuildMessages messages = BuildMessagesImpl.create(projectBuilder, ant.project, underTeamCity)
|
||||
BuildMessages messages = BuildMessagesImpl.create(projectBuilder, ant.project)
|
||||
|
||||
def jdk8Home = JdkUtils.computeJdkHome(messages, "jdk8Home", "$projectHome/build/jdk/1.8", "JDK_18_x64")
|
||||
BuildPathsImpl paths = new BuildPathsImpl(communityHome, projectHome, buildOutputRoot, jdk8Home)
|
||||
@@ -63,14 +60,14 @@ class BuildContextImpl extends BuildContext {
|
||||
|
||||
return new BuildContextImpl(ant, messages, paths, project, global, projectBuilder, productProperties,
|
||||
windowsDistributionCustomizer, linuxDistributionCustomizer, macDistributionCustomizer,
|
||||
macHostProperties, options, signTool, scrambleTool, underTeamCity, outputDirectoriesToKeep)
|
||||
macHostProperties, options, signTool, scrambleTool, outputDirectoriesToKeep)
|
||||
}
|
||||
|
||||
BuildContextImpl(AntBuilder ant, BuildMessages messages, BuildPaths paths, JpsProject project, JpsGlobal global,
|
||||
JpsGantProjectBuilder projectBuilder, ProductProperties productProperties,
|
||||
WindowsDistributionCustomizer windowsDistributionCustomizer, LinuxDistributionCustomizer linuxDistributionCustomizer,
|
||||
MacDistributionCustomizer macDistributionCustomizer,
|
||||
MacHostProperties macHostProperties, BuildOptions options, SignTool signTool, ScrambleTool scrambleTool, boolean underTeamCity,
|
||||
MacHostProperties macHostProperties, BuildOptions options, SignTool signTool, ScrambleTool scrambleTool,
|
||||
List<String> outputDirectoriesToKeep) {
|
||||
this.ant = ant
|
||||
this.messages = messages
|
||||
@@ -84,7 +81,6 @@ class BuildContextImpl extends BuildContext {
|
||||
this.options = options
|
||||
this.signTool = signTool
|
||||
this.scrambleTool = scrambleTool
|
||||
this.underTeamCity = underTeamCity
|
||||
this.outputDirectoriesToKeep = outputDirectoriesToKeep
|
||||
|
||||
bundledJreManager = new BundledJreManager(this, paths.buildOutputRoot)
|
||||
@@ -241,8 +237,8 @@ class BuildContextImpl extends BuildContext {
|
||||
def ant = new AntBuilder(ant.project)
|
||||
def messages = messages.forkForParallelTask(taskName)
|
||||
def child = new BuildContextImpl(ant, messages, paths, project, global, projectBuilder, productProperties,
|
||||
windowsDistributionCustomizer, linuxDistributionCustomizer, macDistributionCustomizer,
|
||||
macHostProperties, options, signTool, scrambleTool, underTeamCity, outputDirectoriesToKeep)
|
||||
windowsDistributionCustomizer, linuxDistributionCustomizer, macDistributionCustomizer,
|
||||
macHostProperties, options, signTool, scrambleTool, outputDirectoriesToKeep)
|
||||
child.bundledJreManager.baseDirectoryForJre = bundledJreManager.baseDirectoryForJre
|
||||
return child
|
||||
}
|
||||
@@ -273,18 +269,17 @@ class BuildContextImpl extends BuildContext {
|
||||
|
||||
@Override
|
||||
void notifyArtifactBuilt(String artifactPath) {
|
||||
if (!underTeamCity) return
|
||||
|
||||
if (!FileUtil.startsWith(FileUtil.toSystemIndependentName(artifactPath), paths.projectHome)) {
|
||||
def file = new File(artifactPath)
|
||||
def baseDir = new File(paths.projectHome)
|
||||
if (!FileUtil.isAncestor(baseDir, file, true)) {
|
||||
messages.warning("Artifact '$artifactPath' is not under '$paths.projectHome', it won't be reported")
|
||||
return
|
||||
}
|
||||
def relativePath = StringUtil.trimStart(artifactPath.substring(paths.projectHome.length()), "/")
|
||||
def file = new File(artifactPath)
|
||||
def relativePath = FileUtil.toSystemIndependentName(FileUtil.getRelativePath(baseDir, file))
|
||||
if (file.isDirectory()) {
|
||||
relativePath += "=>" + file.name
|
||||
}
|
||||
messages.info("##teamcity[publishArtifacts '$relativePath']")
|
||||
messages.artifactBuild(relativePath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,12 @@ class BuildMessagesImpl implements BuildMessages {
|
||||
private final List<BuildMessagesImpl> forkedInstances = []
|
||||
private final List<LogMessage> delayedMessages = []
|
||||
|
||||
static BuildMessagesImpl create(JpsGantProjectBuilder builder, Project antProject, boolean underTeamCity) {
|
||||
static BuildMessagesImpl create(JpsGantProjectBuilder builder, Project antProject) {
|
||||
String key = "IntelliJBuildMessages"
|
||||
def registered = antProject.getReference(key)
|
||||
if (registered != null) return registered as BuildMessagesImpl
|
||||
|
||||
boolean underTeamCity = System.getProperty("teamcity.buildType.id") != null
|
||||
BuildInfoPrinter buildInfoPrinter = underTeamCity ? new TeamCityBuildInfoPrinter() : new DefaultBuildInfoPrinter()
|
||||
builder.buildInfoPrinter = buildInfoPrinter
|
||||
disableAntLogging(antProject)
|
||||
@@ -119,6 +120,11 @@ class BuildMessagesImpl implements BuildMessages {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void artifactBuild(String relativeArtifactPath) {
|
||||
processMessage(new LogMessage(LogMessage.Kind.ARTIFACT_BUILT, relativeArtifactPath))
|
||||
}
|
||||
|
||||
void processMessage(LogMessage message) {
|
||||
if (parentInstance != null) {
|
||||
//It appears that TeamCity currently cannot properly handle log messages from parallel tasks (https://youtrack.jetbrains.com/issue/TW-46515)
|
||||
|
||||
@@ -51,6 +51,9 @@ class ConsoleBuildMessageLogger extends BuildMessageLogger {
|
||||
case LogMessage.Kind.BLOCK_FINISHED:
|
||||
indent--
|
||||
break
|
||||
case LogMessage.Kind.ARTIFACT_BUILT:
|
||||
printMessage("Artifact built: $message.text")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,9 @@ class TeamCityBuildMessageLogger extends BuildMessageLogger {
|
||||
case LogMessage.Kind.BLOCK_FINISHED:
|
||||
printTeamCityMessage("blockClosed", "name='${escape(message.text)}'")
|
||||
break
|
||||
case LogMessage.Kind.ARTIFACT_BUILT:
|
||||
out.println "##teamcity[publishArtifacts '${escape(message.text)}']"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user