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" 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 }