blob: 996864d11fe641f69eae38702f4b31cb335736fd [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.
*/
/**
* This file was created using the `create_project.py` script located in the
* `<AndroidX root>/development/project-creator` directory.
*
* Please use that script when creating a new project, rather than copying an existing project and
* modifying its settings.
*/
import androidx.build.AndroidXConfig
import androidx.build.BuildOnServerKt
import androidx.build.LibraryType
import androidx.build.Publish
import androidx.build.RunApiTasks
plugins {
id("AndroidXPlugin")
id("AndroidXComposePlugin")
}
androidXMultiplatform {
// Compose Desktop is qualified on "desktop" but actually builds as "jvm".
jvm()
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"))
}
}
commonTest {
dependencies {
}
}
jvmMain {
dependsOn(commonMain)
dependencies {
implementation(libs.kotlinStdlib)
implementation(libs.kotlinStdlibJdk8)
implementation(libs.kotlinCoroutinesCore)
}
}
jvmTest {
dependsOn(commonTest)
resources.srcDirs += new File(AndroidXConfig.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()
}
}
// Set golden images path based on whether this is the GitHub or AndroidX repo.
tasks.withType(Test).configureEach {
systemProperties["GOLDEN_PATH"] = getGoldenPath(project).toString()
}
androidx {
name = "Compose Desktop"
type = LibraryType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS
publish = Publish.SNAPSHOT_AND_RELEASE
inceptionYear = "2020"
legacyDisableKotlinStrictApiMode = true
runApiTasks = new RunApiTasks.No("Not supported yet, see b/163110180")
// samples(project(":compose:desktop:desktop:desktop-samples")) // doesn't publish source jars
// Project parser does not support dynamic configuration of `publish`.
runProjectParser = false
}
def jvmOs(container, name, skikoDep) {
container.create("jvm$name", MavenPublication) {
artifactId = "${project.name}-jvm-$name"
def projectGroup = project.group
def projectName = project.name
def composeVersion = androidx.LibraryVersions.COMPOSE
def skikoModule = skikoDep.module
def skikoVersion = skikoDep.versionConstraint.requiredVersion
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")
def skikoDependency = dependenciesNode.appendNode("dependency")
skikoDependency.appendNode("groupId", skikoModule.group)
skikoDependency.appendNode("artifactId", skikoModule.name)
skikoDependency.appendNode("version", skikoVersion)
skikoDependency.appendNode("scope", "runtime")
}
}
}
}
// Set up additional publications containing native Skiko dependencies.
afterEvaluate {
publishing {
publications {
jvmOs(it, "linux-x64", libs.skikoLinuxX64.get())
jvmOs(it, "linux-arm64", libs.skikoLinuxArm64.get())
jvmOs(it, "macos-x64", libs.skikoMacOsX64.get())
jvmOs(it, "macos-arm64", libs.skikoMacOsArm64.get())
jvmOs(it, "windows-x64", libs.skikoWindowsX64.get())
}
}
}
// Validate desktop build by explicitly building the jvmJar task as part of bOS.
BuildOnServerKt.addToBuildOnServer(project, "${project.path}:jvmJar")