-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/dev/icerock/moko/gradle/HostsPublicationPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.gradle | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.withType | ||
|
||
class HostsPublicationPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
target.plugins.withId("org.gradle.maven-publish") { | ||
target.configure<PublishingExtension> { | ||
val publicationsFromMainHost = listOf( | ||
"wasm32", | ||
"jvm", | ||
"js", | ||
"kotlinMultiplatform", | ||
"androidRelease", | ||
"androidDebug", | ||
"linuxArm64", | ||
"linuxArm32Hfp", | ||
"linuxX64" | ||
) | ||
|
||
target.tasks.withType<AbstractPublishToMaven>() | ||
.matching { it.publication?.name in publicationsFromMainHost } | ||
.configureEach { onlyIf { System.getProperty("IS_MAIN_HOST") == "true" } } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.gradle | ||
|
||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.get | ||
import org.gradle.kotlin.dsl.register | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
class JvmPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target.plugins) { | ||
apply("org.jetbrains.kotlin.jvm") | ||
} | ||
|
||
target.configure<JavaPluginExtension> { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
target.tasks | ||
.withType<KotlinCompile>() | ||
.configureEach { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
target.plugins.withId("org.gradle.maven-publish") { | ||
target.configure<PublishingExtension> { | ||
publications.register("mavenJava", MavenPublication::class) { | ||
from(target.components["java"]) | ||
} | ||
} | ||
} | ||
} | ||
} |