Skip to content

Commit 8933ee5

Browse files
authored
Use a separate build structure for maintaining fork (#3064)
Part of [CMP-10017](https://youtrack.jetbrains.com/issue/CMP-10017) Simplify merges short-term. Make buildSrc/build.gradle for the fork mode The reason is to simplify regular AOSP merges. There are 2 modes: - AOSP mode. used if it is opened via `gradlew studio` - fork mode. used if it is opened via IDEA. The build fork is separated using this code: ``` def isRunFromGradlewStudio = System.getenv().get("EXPECTED_AGP_VERSION") if (!isRunFromGradlewStudio) { apply from: "settings-fork.gradle" return } ``` This works, but not ideally because some parts of the build are still shared with AOSP and we need to review them during the merge: ``` gradle.properties gradle/wrapper gradle/libs.version.toml buildSrc/gradle.properties ``` Alternatives that I tried: - create `fork-project`, add symlinks to the top-level projects. Didn't work because integration with Git is broken (the changed files are treated as not a part of the project) - create `fork-project`, use `../project` paths to the top-level projects. Didn't work because running from the gutter is broken (IDEA tells that the project folder isn't part of the root project) Next steps: 1. [Support using sources instead of androidx artifacts](#3169) 2. Merge it into `integration` 3. Reset state of `buildSrc`, `build.gradle` to the AOSP state (excluding the code that redirects to the fork) 4. Add an automatic task that compares source sets dependencies inside `build-fork.gradle` 5. Clean up `buildSrc` from not needed code [TeamCity](https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_AllPersonalBuild/6263205) Should be reviewed commit by commit. ## Release Notes N/A
2 parents 1e6c2c0 + 442bb6b commit 8933ee5

361 files changed

Lines changed: 43701 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2019 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id("AndroidXPlugin")
19+
id("kotlin")
20+
}
21+
22+
dependencies {
23+
}
24+

build-fork.gradle

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2019 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* This file was created using the `create_project.py` script located in the
19+
* `<AndroidX root>/development/project-creator` directory.
20+
*
21+
* Please use that script when creating a new project, rather than copying an existing project and
22+
* modifying its settings.
23+
*/
24+
import androidx.build.AndroidXRootPlugin
25+
import androidx.build.SdkHelperKt
26+
import org.jetbrains.androidx.build.JetBrainsAndroidXRootPlugin
27+
28+
buildscript {
29+
SdkHelperKt.setSupportRootFolder(project, project.projectDir)
30+
31+
// Needed for atomicfu plugin
32+
apply(from: "buildSrc/repos.gradle")
33+
repos.addMavenRepositories(repositories)
34+
}
35+
36+
apply plugin: AndroidXRootPlugin
37+
apply plugin: JetBrainsAndroidXRootPlugin

buildSrc-fork/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
buildscript {
2+
project.ext.supportRootFolder = project.projectDir.getParentFile()
3+
apply from: "repos.gradle"
4+
repos.addMavenRepositories(repositories)
5+
6+
dependencies {
7+
classpath(libs.kotlinGradlePlugin)
8+
}
9+
10+
configurations.classpath.resolutionStrategy {
11+
eachDependency { details ->
12+
if (details.requested.group == "org.jetbrains.kotlin") {
13+
details.useVersion libs.versions.kotlin.get()
14+
}
15+
}
16+
}
17+
}
18+
19+
ext.supportRootFolder = project.projectDir.getParentFile()
20+
apply from: "repos.gradle"
21+
apply plugin: "kotlin"
22+
23+
repos.addMavenRepositories(repositories)
24+
25+
project.tasks.withType(Jar).configureEach { task ->
26+
task.reproducibleFileOrder = true
27+
task.preserveFileTimestamps = false
28+
}
29+
30+
dependencies {
31+
api(project("plugins"))
32+
}

buildSrc-fork/imports/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This directory contains projects that just mirror the corresponding project in the main build in ../..
2+
3+
This may be useful if a project in ../.. creates a plugin that another project wants to apply
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply from: "../../shared.gradle"
2+
apply plugin: "java-gradle-plugin"
3+
4+
sourceSets {
5+
main.java.srcDirs += "${supportRootFolder}" +
6+
"/benchmark/baseline-profile-gradle-plugin/src/main/kotlin"
7+
main.resources.srcDirs += "${supportRootFolder}" +
8+
"/benchmark/baseline-profile-gradle-plugin/src/main/resources"
9+
}
10+
11+
gradlePlugin {
12+
plugins {
13+
baselineProfileProducer {
14+
id = "androidx.baselineprofile.producer"
15+
implementationClass = "androidx.baselineprofile.gradle.producer.BaselineProfileProducerPlugin"
16+
}
17+
baselineProfileConsumer {
18+
id = "androidx.baselineprofile.consumer"
19+
implementationClass = "androidx.baselineprofile.gradle.consumer.BaselineProfileConsumerPlugin"
20+
}
21+
baselineProfileAppTarget {
22+
id = "androidx.baselineprofile.apptarget"
23+
implementationClass = "androidx.baselineprofile.gradle.apptarget.BaselineProfileAppTargetPlugin"
24+
}
25+
baselineProfileWrapper {
26+
id = "androidx.baselineprofile"
27+
implementationClass = "androidx.baselineprofile.gradle.wrapper.BaselineProfileWrapperPlugin"
28+
}
29+
}
30+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apply from: "../../shared.gradle"
2+
apply plugin: "java-gradle-plugin"
3+
4+
sourceSets {
5+
main.java.srcDirs += "${supportRootFolder}/benchmark/benchmark-darwin-gradle-plugin/src/main/kotlin"
6+
main.resources.srcDirs += "${supportRootFolder}/benchmark/benchmark-darwin-gradle-plugin/src/main/resources"
7+
}
8+
9+
dependencies {
10+
implementation(libs.apacheCommonsMath)
11+
}
12+
13+
gradlePlugin {
14+
plugins {
15+
darwinBenchmark {
16+
id = "androidx.benchmark.darwin"
17+
implementationClass = "androidx.benchmark.darwin.gradle.DarwinBenchmarkPlugin"
18+
}
19+
}
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apply from: "../../shared.gradle"
2+
apply plugin: "java-gradle-plugin"
3+
4+
sourceSets {
5+
main.java.srcDirs += "${supportRootFolder}/benchmark/gradle-plugin/src/main/kotlin"
6+
main.resources.srcDirs += "${supportRootFolder}/benchmark/gradle-plugin/src/main/resources"
7+
}
8+
9+
gradlePlugin {
10+
plugins {
11+
benchmark {
12+
id = "androidx.benchmark"
13+
implementationClass = "androidx.benchmark.gradle.BenchmarkPlugin"
14+
}
15+
}
16+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply from: "../../shared.gradle"
18+
19+
// TODO(b/410631668): remove when "kotlin-compiler" is no longer added to "friendPaths"
20+
// Workaround for Windows to solve
21+
// "this and base files have different roots: C:\Users\User\.gradle\caches\modules-2\...\kotlin-compiler-2.2.10.jar and D:\compose-multiplatform-core\out\buildSrc\imports\binary-compatibility-validator\build"
22+
//
23+
// This happens because "friendPaths" is set and it doesn't support different roots (C: and D:)
24+
// kotlin-compiler was added to "friendsPath" in
25+
// https://android-review.googlesource.com/c/platform/frameworks/support/+/3636427
26+
//
27+
// This moves the build directory to the Gradle cache directory for this module,
28+
// which is an anti-pattern but solves the issue
29+
if (System.properties['os.name']?.toString()?.toLowerCase()?.contains('windows') == true) {
30+
layout.buildDirectory = file("${gradle.gradleUserHomeDir}/compose-multipltform-core-build/buildSrc-imports-binary-compatibility-validator")
31+
}
32+
33+
sourceSets {
34+
main.java.srcDirs += "${supportRootFolder}/binarycompatibilityvalidator/" +
35+
"binarycompatibilityvalidator/src/jvmMain/kotlin"
36+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apply from: "../../shared.gradle"
2+
3+
sourceSets {
4+
main.java.srcDirs += "${supportRootFolder}/glance/glance-appwidget/glance-layout-generator/" +
5+
"src/main/kotlin"
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apply from: "../../shared.gradle"
2+
apply plugin: "java-gradle-plugin"
3+
4+
sourceSets {
5+
main.java.srcDirs += "${supportRootFolder}/inspection/inspection-gradle-plugin/src/main/kotlin"
6+
main.resources.srcDirs += "${supportRootFolder}/inspection/inspection-gradle-plugin/src/main" +
7+
"/resources"
8+
}
9+
10+
gradlePlugin {
11+
plugins {
12+
inspection {
13+
id = "androidx.inspection"
14+
implementationClass = "androidx.inspection.gradle.InspectionPlugin"
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)