[repo] Migrate 'manifestAttributes()' into buildSrc

This commit is contained in:
Yahor Berdnikau
2023-06-30 20:39:20 +02:00
committed by Space Team
parent db1086f005
commit 7bfe59253f
18 changed files with 49 additions and 35 deletions
@@ -5,9 +5,11 @@
@file:JvmName("LibrariesCommon")
import gradle.kotlin.dsl.accessors._a448c82b4669f5dc55622c27b71461fb.base
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.java.archives.Manifest
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.*
import org.gradle.process.CommandLineArgumentProvider
@@ -79,3 +81,30 @@ fun Project.configureFrontendIr() = tasks.withType<KotlinJvmCompile>().configure
}
}
}
@JvmOverloads
fun Project.manifestAttributes(
manifest: Manifest,
component: String? = null,
multiRelease: Boolean = false
) {
manifest.attributes(
"Implementation-Vendor" to "JetBrains",
"Implementation-Title" to base.archivesName,
"Implementation-Version" to project.rootProject.extra["buildNumber"] as String
)
if (component != null) {
val kotlinLanguageVersion: String by rootProject.extra
manifest.attributes(
"Kotlin-Runtime-Component" to component,
"Kotlin-Version" to kotlinLanguageVersion
)
}
if (multiRelease) {
manifest.attributes(
"Multi-Release" to "true"
)
}
}
-19
View File
@@ -1,22 +1,3 @@
ext.manifestAttributes = { Manifest manifest, Project project, String component = null, boolean multiRelease = false ->
project.configure(manifest) {
attributes \
'Implementation-Vendor': 'JetBrains',
'Implementation-Title': project.archivesBaseName,
'Implementation-Version': project.buildNumber
if (component != null) {
attributes \
'Kotlin-Runtime-Component': component,
'Kotlin-Version': project.kotlinLanguageVersion
}
if (multiRelease) {
attributes \
'Multi-Release': 'true'
}
}
}
task preparePublication {
def properties = project.properties
assert project.version != 'unspecified'
@@ -14,7 +14,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile) {
}
jar {
manifestAttributes(manifest, project, 'Test')
LibrariesCommon.manifestAttributes(project, manifest, 'Test')
}
RepoArtifacts.sourcesJar(project)
+1 -1
View File
@@ -10,7 +10,7 @@ dependencies {
}
jar {
manifestAttributes(manifest, project, 'Test')
LibrariesCommon.manifestAttributes(project, manifest, 'Test')
}
RepoArtifacts.sourcesJar(project)
+1 -1
View File
@@ -49,7 +49,7 @@ tasks.register("libraryJarWithoutIr", Jar) {
archiveClassifier.set(null)
destinationDirectory = file("$buildDir/lib/dist")
from("$buildDir/classes/main")
manifestAttributes(manifest, project, 'Test')
LibrariesCommon.manifestAttributes(project, manifest, 'Test')
}
tasks.register("libraryJarWithIr", Zip) {
+1 -1
View File
@@ -20,7 +20,7 @@ dependencies {
jar {
manifestAttributes(manifest, project, 'Test', true)
LibrariesCommon.manifestAttributes(project, manifest, 'Test', true)
if (includeJava9) {
from sourceSets.java9.output
}
+1 -1
View File
@@ -21,7 +21,7 @@ dependencies {
}
jar {
manifestAttributes(manifest, project, 'Test', true)
LibrariesCommon.manifestAttributes(project, manifest, 'Test', true)
if (includeJava9) {
from sourceSets.java9.output
}
+1 -1
View File
@@ -22,7 +22,7 @@ dependencies {
}
jar {
manifestAttributes(manifest, project, 'Test', true)
LibrariesCommon.manifestAttributes(project, manifest, 'Test', true)
if (includeJava9) {
from sourceSets.java9.output
}
+1 -1
View File
@@ -22,7 +22,7 @@ dependencies {
}
jar {
manifestAttributes(manifest, project, 'Test', true)
LibrariesCommon.manifestAttributes(project, manifest, 'Test', true)
if (includeJava9) {
from sourceSets.java9.output
}
+1 -1
View File
@@ -62,7 +62,7 @@ compileKotlin {
LibrariesCommon.configureFrontendIr(project)
jar {
manifestAttributes(manifest, project, "internal")
LibrariesCommon.manifestAttributes(project, manifest, "internal")
}
tasks.register("java9Jar", Jar) {
+5 -1
View File
@@ -238,7 +238,11 @@ val result by task<Jar> {
from(zipTree(provider { reflectShadowJar.get().archiveFile.get().asFile })) {
include("META-INF/versions/**")
}
callGroovy("manifestAttributes", manifest, project, "Main", true)
manifestAttributes(
manifest,
component = "Main",
multiRelease = true
)
}
javadocJar()
+1 -1
View File
@@ -63,7 +63,7 @@ compileTestKotlinCommon {
}
jar {
manifestAttributes(manifest, project, 'Main')
LibrariesCommon.manifestAttributes(project, manifest, 'Main')
}
RepoArtifacts.sourcesJar(project)
+1 -1
View File
@@ -30,7 +30,7 @@ dependencies {
}
jar {
manifestAttributes(manifest, project, 'Main', true)
LibrariesCommon.manifestAttributes(project, manifest, 'Main', true)
from sourceSets.java9.output
}
+1 -1
View File
@@ -42,7 +42,7 @@ dependencies {
}
jar {
manifestAttributes(manifest, project, 'Main', true)
LibrariesCommon.manifestAttributes(project, manifest, 'Main', true)
from sourceSets.java9.output
}
+1 -1
View File
@@ -247,7 +247,7 @@ jar {
tasks.register("libraryJarWithoutIr", Jar) {
dependsOn(compileJs)
archiveClassifier = null
manifestAttributes(manifest, project, 'Main')
LibrariesCommon.manifestAttributes(project, manifest, 'Main')
destinationDirectory = file("$buildDir/lib/dist")
// TODO: Use standard implementation title after js stdlib detector becomes more flexible (KT-17655)
+1 -1
View File
@@ -97,7 +97,7 @@ dependencies {
tasks.named("jar", Jar) {
dependsOn(configurations.builtins)
manifestAttributes(manifest, project, 'Main', true)
LibrariesCommon.manifestAttributes(project, manifest, 'Main', true)
from {
zipTree(configurations.builtins.singleFile)
}
@@ -37,5 +37,5 @@ tasks.named<KotlinJvmCompile>("compileTestFixturesKotlin") {
}
tasks.named<Jar>("jar") {
callGroovy("manifestAttributes", manifest, project)
manifestAttributes(manifest)
}
+1 -1
View File
@@ -19,7 +19,7 @@ sourceSets {
}
jar {
manifestAttributes(manifest, project, 'Main')
LibrariesCommon.manifestAttributes(project, manifest, 'Main')
}
RepoArtifacts.sourcesJar(project)