blob: 8c9863c07bf1fecc7a58578368ede655f45fefbf [file] [log] [blame]
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import androidx.build.LibraryType
import androidx.build.RunApiTasks
import androidx.build.BuildOnServerKt
import androidx.build.SupportConfigKt
plugins {
id("AndroidXPlugin")
id("java") // https://github.com/gradle/gradle/issues/18622
id("AndroidXComposePlugin")
id("kotlin-multiplatform")
}
dependencies {
kotlinPlugin(project(":compose:compiler:compiler"))
}
kotlin {
jvm() {
withJava()
}
sourceSets {
commonMain.dependencies {
implementation(libs.kotlinStdlibCommon)
implementation(project(":compose:ui:ui-util"))
api(project(":compose:foundation:foundation"))
api(project(":compose:material:material"))
api(project(":compose:runtime:runtime"))
api(project(":compose:ui:ui"))
api(project(":compose:ui:ui-tooling-preview"))
}
jvmMain.dependencies {
implementation(libs.kotlinStdlib)
implementation(libs.kotlinStdlibJdk8)
implementation(libs.kotlinCoroutinesCore)
}
jvmTest {
resources.srcDirs += new File(SupportConfigKt.getExternalProjectPath(project), "noto-fonts/other/")
resources.srcDirs += "src/jvmTest/res"
dependencies {
implementation(libs.kotlinCoroutinesTest)
implementation(libs.skikoCurrentOs)
implementation(project(":compose:ui:ui-test-junit4"))
implementation(libs.junit)
implementation(libs.truth)
}
}
}
}
File getGoldenPath(Project project) {
if (System.getenv("COMPOSE_DESKTOP_GITHUB_BUILD") != null) {
def externalPath = SupportConfigKt.getExternalProjectPath(project)
return new File(externalPath, "golden")
} else {
return new File("${rootDir.absolutePath}/../../golden").getCanonicalFile()
}
}
tasks.findByName("jvmTest").configure {
systemProperties["GOLDEN_PATH"] = getGoldenPath(project).toString()
}
androidx {
name = "Jetpack Compose desktop implementation"
type = LibraryType.PUBLISHED_LIBRARY
mavenGroup = LibraryGroups.COMPOSE_DESKTOP
inceptionYear = "2020"
legacyDisableKotlinStrictApiMode = true
runApiTasks = new RunApiTasks.No(
"API tracking for desktop isn't supported at the moment, see b/163110180"
)
}
PublicationContainer.metaClass.jvmOs = { name, skikoDeps ->
delegate.create("jvm$name", MavenPublication) {
artifactId = "${project.name}-jvm-$name"
def projectGroup = project.group
def projectName = project.name
def composeVersion = androidx.LibraryVersions.COMPOSE
pom {
withXml {
def dependenciesNode = asNode().appendNode("dependencies")
def desktopDependency = dependenciesNode.appendNode("dependency")
desktopDependency.appendNode("groupId", projectGroup)
desktopDependency.appendNode("artifactId", projectName)
desktopDependency.appendNode("version", composeVersion)
desktopDependency.appendNode("scope", "compile")
for (skiko in skikoDeps) {
def skikoModule = skiko.get().module
def skikoVersion = skiko.get().versionConstraint.requiredVersion
def skikoDependency = dependenciesNode.appendNode("dependency")
skikoDependency.appendNode("groupId", skikoModule.group)
skikoDependency.appendNode("artifactId", skikoModule.name)
skikoDependency.appendNode("version", skikoVersion)
skikoDependency.appendNode("scope", "runtime")
}
}
}
}
}
afterEvaluate {
publishing {
publications {
it.jvmOs("linux-x64", [libs.skikoLinuxX64])
it.jvmOs("linux-arm64", [libs.skikoLinuxArm64])
it.jvmOs("macos-x64", [libs.skikoMacOsX64])
it.jvmOs("macos-arm64", [libs.skikoMacOsArm64])
it.jvmOs("windows-x64", [libs.skikoWindowsX64])
}
}
}
BuildOnServerKt.addToBuildOnServer(project, "${project.path}:jvmJar")