-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decoupling plugin from buildScript #47
Conversation
MarcoSignoretto
commented
Aug 10, 2021
- Moved the plugin on its standalone module to be able to publish
- Refactor and clean up
- Gradle wrapper upgrade
* Moved the plugin on its standalone module to be able to publish * Refactor and clean up * Gradle wrapper upgrade
aef7c8f
to
9c4cff5
Compare
import org.gradle.initialization.DependenciesAccessors | ||
import org.gradle.kotlin.dsl.support.serviceOf | ||
|
||
/** | ||
* | ||
* Copyright Careem, an Uber Technologies Inc. company | ||
* | ||
* 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. | ||
*/ | ||
|
||
enableFeaturePreview("VERSION_CATALOGS") | ||
|
||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
includeBuild("..") { | ||
dependencySubstitution { | ||
substitute(module("com.careem.mockingbird:mockingbird")).using(project(":mockingbird")) | ||
substitute(module("com.careem.mockingbird:mockingbird-compiler")).using(project(":mockingbird-compiler")) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes samples a standalone project, allowing to use local plugin definition ( inspired by Sqldelight )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, TIL.
} | ||
} | ||
|
||
void setupMultiplatformLibrary(Project project, Boolean shouldPublish = true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted this in utils.gradle
@@ -20,6 +20,8 @@ plugins { | |||
`kotlin-dsl` | |||
} | |||
|
|||
apply(from = "../publishing.gradle") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allow to publish the gradle plugin
setupMultiplatformLibrary(project, false) | ||
setupAllTargetsWithDefaultSourceSets(project, false) // FIXME Js excluded here | ||
|
||
apply plugin: "com.careem.mockingbird" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apply plugin as any external plugin
|
||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
implementation project(":mockingbird") | ||
implementation "com.careem.mockingbird:mockingbird" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will use the local module because set in dependency resolution strategy
void setupAllTargetsWithDefaultSourceSets(Project project, Boolean includeJs = true) { | ||
setupIosTargets(project) | ||
setupJvmTarget(project) | ||
if(includeJs){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add this since JsPlugin is in buildSrc but buildSrc is not available in sample
@@ -0,0 +1,26 @@ | |||
<component name="ProjectCodeStyleConfiguration"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the long term, let's migrate to .editorconfig
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, doies this file provide any advantages over setting code style to official
in gradle.properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it has also the import settings that can be moved into .editorconfig
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the migration to .editorconfig
out of scope for this PR
import org.gradle.initialization.DependenciesAccessors | ||
import org.gradle.kotlin.dsl.support.serviceOf | ||
|
||
/** | ||
* | ||
* Copyright Careem, an Uber Technologies Inc. company | ||
* | ||
* 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. | ||
*/ | ||
|
||
enableFeaturePreview("VERSION_CATALOGS") | ||
|
||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
includeBuild("..") { | ||
dependencySubstitution { | ||
substitute(module("com.careem.mockingbird:mockingbird")).using(project(":mockingbird")) | ||
substitute(module("com.careem.mockingbird:mockingbird-compiler")).using(project(":mockingbird-compiler")) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, TIL.