-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support custom version or coordinates for Compose compiler (#283)
Since this project does not build a Kotlin compiler plugin, we should not be forced to do a release for new versions of Kotlin. This property will allow consumers to upgrade thier Kotlin version by specifying a newer JetBrains Compose compiler version, or a totally different set of Maven coordiantes for a custom Compose compiler aritfact.
- Loading branch information
1 parent
4cd7c87
commit 391874b
Showing
12 changed files
with
217 additions
and
11 deletions.
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
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
40 changes: 40 additions & 0 deletions
40
molecule-gradle-plugin/src/main/java/app/cash/molecule/gradle/MoleculeExtension.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,40 @@ | ||
/* | ||
* Copyright (C) 2023 Square, Inc. | ||
* | ||
* 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. | ||
*/ | ||
package app.cash.molecule.gradle | ||
|
||
import org.gradle.api.provider.Property | ||
|
||
interface MoleculeExtension { | ||
/** | ||
* The version of the JetBrains Compose compiler to use, or a Maven coordinate triple of | ||
* the custom Compose compiler to use. | ||
* | ||
* Example: using a custom version of the JetBrains Compose compiler | ||
* ```kotlin | ||
* redwood { | ||
* kotlinCompilerPlugin.set("1.4.8") | ||
* } | ||
* ``` | ||
* | ||
* Example: using a custom Maven coordinate for the Compose compiler | ||
* ```kotlin | ||
* redwood { | ||
* kotlinCompilerPlugin.set("com.example:custom-compose-compiler:1.0.0") | ||
* } | ||
* ``` | ||
*/ | ||
val kotlinCompilerPlugin: Property<String> | ||
} |
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
30 changes: 30 additions & 0 deletions
30
molecule-gradle-plugin/src/test/fixtures/custom-compiler-coordinates/build.gradle
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,30 @@ | ||
buildscript { | ||
dependencies { | ||
classpath "app.cash.molecule:molecule-gradle-plugin:$moleculeVersion" | ||
classpath libs.kotlin.plugin | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "file://${rootDir.absolutePath}/../../../../../build/localMaven" | ||
} | ||
mavenCentral() | ||
google() | ||
} | ||
} | ||
|
||
apply plugin: 'org.jetbrains.kotlin.jvm' | ||
apply plugin: 'app.cash.molecule' | ||
|
||
molecule { | ||
// Use the AndroidX Compose compiler instead of JetBrains Compose compiler. | ||
kotlinCompilerPlugin = libs.androidx.compose.compiler.get().toString() | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "file://${rootDir.absolutePath}/../../../../../build/localMaven" | ||
} | ||
mavenCentral() | ||
google() | ||
} |
7 changes: 7 additions & 0 deletions
7
molecule-gradle-plugin/src/test/fixtures/custom-compiler-coordinates/settings.gradle
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,7 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
libs { | ||
from(files('../../../../../gradle/libs.versions.toml')) | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
molecule-gradle-plugin/src/test/fixtures/custom-compiler-invalid/build.gradle
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,29 @@ | ||
buildscript { | ||
dependencies { | ||
classpath "app.cash.molecule:molecule-gradle-plugin:$moleculeVersion" | ||
classpath libs.kotlin.plugin | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "file://${rootDir.absolutePath}/../../../../../build/localMaven" | ||
} | ||
mavenCentral() | ||
google() | ||
} | ||
} | ||
|
||
apply plugin: 'org.jetbrains.kotlin.jvm' | ||
apply plugin: 'app.cash.molecule' | ||
|
||
molecule { | ||
kotlinCompilerPlugin = 'wrong:format' | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "file://${rootDir.absolutePath}/../../../../../build/localMaven" | ||
} | ||
mavenCentral() | ||
google() | ||
} |
7 changes: 7 additions & 0 deletions
7
molecule-gradle-plugin/src/test/fixtures/custom-compiler-invalid/settings.gradle
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,7 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
libs { | ||
from(files('../../../../../gradle/libs.versions.toml')) | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
molecule-gradle-plugin/src/test/fixtures/custom-compiler-version/build.gradle
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,36 @@ | ||
buildscript { | ||
ext.kotlinVersion = '1.8.20' | ||
|
||
dependencies { | ||
classpath "app.cash.molecule:molecule-gradle-plugin:$moleculeVersion" | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "file://${rootDir.absolutePath}/../../../../../build/localMaven" | ||
} | ||
mavenCentral() | ||
google() | ||
} | ||
} | ||
|
||
if (kotlinVersion == libs.kotlin.plugin.get().version) { | ||
throw RuntimeException("This test requires a different version of Kotlin then the Molecule build") | ||
} | ||
|
||
apply plugin: 'org.jetbrains.kotlin.jvm' | ||
apply plugin: 'app.cash.molecule' | ||
|
||
molecule { | ||
// Use the JetBrains Compose compiler version for the version of Kotlin used by this project. | ||
kotlinCompilerPlugin = '1.4.8' | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "file://${rootDir.absolutePath}/../../../../../build/localMaven" | ||
} | ||
mavenCentral() | ||
google() | ||
} |
7 changes: 7 additions & 0 deletions
7
molecule-gradle-plugin/src/test/fixtures/custom-compiler-version/settings.gradle
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,7 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
libs { | ||
from(files('../../../../../gradle/libs.versions.toml')) | ||
} | ||
} | ||
} |
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