Files
kotlin-fork/libraries/examples/kotlin-gradle-subplugin-example/build.gradle
T
Yan Zhulanow 1fb8fb2324 [Pill] Do not import modules with the 'FULL' variant
The 'FULL' variant proved to be hardly useful for everyday work.
This change is the first step of removing the variant support from Pill.
2023-12-07 08:53:35 +00:00

115 lines
3.6 KiB
Groovy

import plugins.KotlinBuildPublishingPlugin
plugins {
id("java-gradle-plugin")
id("org.jetbrains.kotlin.jvm")
id("com.gradle.plugin-publish")
id("maven-publish")
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
api project(':kotlin-gradle-plugin-api')
// Use this dependency instead when building apart from the other modules:
// compile "org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kotlin_version"
api project(':kotlin-test:kotlin-test-junit')
compileOnly RepoDependencies.kotlinStdlib(project)
compileOnly project(':compiler')
compileOnly project(':compiler:plugin-api')
compileOnly project(':compiler:cli-common')
compileOnly project(':compiler:cli')
compileOnly gradleApi()
compileOnly project(':dependencies:intellij-core')
}
GradleCommonKt.configureCommonPublicationSettingsForGradle(project, false, false)
GradleCommonKt.configureKotlinCompileTasksGradleCompatibility(project)
GradleCommonKt.excludeGradleCommonDependencies(project, sourceSets.main)
TasksKt.optInToExperimentalCompilerApi(project)
extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false"
// You should configure your own Gradle plugin publication!
//extensions.configure(GradlePluginDevelopmentExtension) {
// it.setAutomatedPublishing(false)
//}
def sourceSet = sourceSets.main
def jarTask = tasks.named(sourceSet.jarTaskName, Jar) {
archiveClassifier.set("unshaded")
}
def shadowJarTask = EmbeddableKt.embeddableCompilerDummyForDependenciesRewriting(
project,
"${EmbeddableKt.EMBEDDABLE_COMPILER_TASK_NAME}${sourceSet.jarTaskName.capitalize()}"
) {
def emptyClassifier = provider { "" }
RepoArtifacts.setupPublicJar(
it,
jarTask.flatMap { it.archiveBaseName },
jarTask.flatMap { emptyClassifier }
)
RepoArtifacts.addEmbeddedRuntime(it)
it.from(sourceSet.output)
// When Gradle traverses the inputs, reject the shaded compiler JAR,
// which leads to the content of that JAR being excluded as well:
def compilerDummyJarFile = project.provider { project.configurations.getByName("compilerDummyJar").singleFile }
it.exclude { it.file == compilerDummyJarFile.get() }
}
// Removing artifact produced by Jar task
configurations[sourceSet.runtimeElementsConfigurationName].artifacts.removeAll { true }
configurations[sourceSet.apiElementsConfigurationName].artifacts.removeAll { true }
// Adding instead artifact from shadow jar task
artifacts {
add(sourceSet.runtimeElementsConfigurationName, shadowJarTask)
add(sourceSet.apiElementsConfigurationName, shadowJarTask)
}
publishing {
publications {
it.withType(MavenPublication).configureEach {
if (name.endsWith("PluginMarkerMaven")) {
pom {
// https://github.com/gradle/gradle/issues/8754
// and https://github.com/gradle/gradle/issues/6155
packaging = "pom"
}
}
}
}
}
gradlePlugin {
plugins {
create("gradle-subplugin-example") {
id = "org.jetbrains.kotlin.gradle-subplugin-example"
implementationClass = "example.ExampleSubplugin"
displayName = "Kotlin Gradle subplugin example"
}
}
}
// Disable releasing for this plugin
// It is not intended to be released publicly
tasks.withType(PublishToMavenRepository)
.configureEach {
if (it.name.endsWith("PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository")) {
setEnabled(false)
}
}
tasks.named("publishPlugins") {
enabled = false
}