Build: Add diagnostic for publish() helper
This commit is contained in:
@@ -35,14 +35,26 @@ fun Project.testsJar(body: Jar.() -> Unit = {}): Jar {
|
||||
}
|
||||
}
|
||||
|
||||
var Project.artifactsRemovedDiagnosticFlag: Boolean
|
||||
get() = extra.has("artifactsRemovedDiagnosticFlag") && extra["artifactsRemovedDiagnosticFlag"] == true
|
||||
set(value) {
|
||||
extra["artifactsRemovedDiagnosticFlag"] = value
|
||||
}
|
||||
|
||||
fun Project.removeArtifacts(configuration: Configuration, task: Task) {
|
||||
configuration.artifacts.removeAll { artifact ->
|
||||
artifact.file in task.outputs.files
|
||||
}
|
||||
|
||||
artifactsRemovedDiagnosticFlag = true
|
||||
}
|
||||
|
||||
fun Project.noDefaultJar() {
|
||||
tasks.findByName("jar")?.let { defaultJarTask ->
|
||||
defaultJarTask.enabled = false
|
||||
defaultJarTask.actions = emptyList()
|
||||
configurations.forEach { cfg ->
|
||||
cfg.artifacts.removeAll { artifact ->
|
||||
artifact.file in defaultJarTask.outputs.files
|
||||
}
|
||||
removeArtifacts(cfg, defaultJarTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,8 +70,7 @@ fun Project.runtimeJarArtifactBy(task: Task, artifactRef: Any, body: Configurabl
|
||||
fun <T : Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
|
||||
extra["runtimeJarTask"] = task
|
||||
tasks.findByName("jar")?.let { defaultJarTask ->
|
||||
configurations.getOrCreate("archives")
|
||||
.artifacts.removeAll { artifact -> artifact.file in defaultJarTask.outputs.files }
|
||||
removeArtifacts(configurations.getOrCreate("archives"), defaultJarTask)
|
||||
}
|
||||
return task.apply {
|
||||
setupPublicJar(project.the<BasePluginConvention>().archivesBaseName)
|
||||
@@ -109,6 +120,10 @@ fun Project.standardPublicJars() {
|
||||
fun Project.publish(body: Upload.() -> Unit = {}): Upload {
|
||||
apply<plugins.PublishedKotlinModule>()
|
||||
|
||||
if (artifactsRemovedDiagnosticFlag) {
|
||||
error("`publish()` should be called before removing artifacts typically done in `noDefaultJar()` of `runtimeJar()` calls")
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
if (configurations.findByName("classes-dirs") != null)
|
||||
throw GradleException("classesDirsArtifact() is incompatible with publish(), see sources comments for details")
|
||||
|
||||
@@ -99,6 +99,8 @@ dependencies {
|
||||
fatJarContentsStripServices(intellijDep("jps-standalone")) { includeJars("jps-model") }
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
noDefaultJar()
|
||||
|
||||
val packCompiler by task<ShadowJar> {
|
||||
@@ -154,8 +156,6 @@ dist(targetName = "$compilerBaseName.jar", fromTask = pack) {
|
||||
from(trove4jJar)
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
|
||||
name = compilerBaseName
|
||||
classifier = ""
|
||||
|
||||
@@ -91,6 +91,8 @@ dependencies {
|
||||
fatJarContentsStripMetadata(intellijDep()) { includeJars("oro-2.0.8", "jdom", "log4j" ) }
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
noDefaultJar()
|
||||
|
||||
val packCompiler by task<ShadowJar> {
|
||||
@@ -146,8 +148,6 @@ dist(targetName = "$compilerBaseName.jar", fromTask = pack) {
|
||||
from(trove4jJar)
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
|
||||
name = compilerBaseName
|
||||
classifier = ""
|
||||
@@ -158,4 +158,3 @@ sourcesJar {
|
||||
}
|
||||
|
||||
javadocJar()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user