Skip to content
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

Merged
merged 7 commits into from
Aug 24, 2021
Merged

Conversation

MarcoSignoretto
Copy link
Collaborator

  • 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
Comment on lines +1 to +36
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"))
}
}
Copy link
Collaborator Author

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 )

Copy link
Member

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) {
Copy link
Collaborator Author

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")
Copy link
Collaborator Author

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"
Copy link
Collaborator Author

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"
Copy link
Collaborator Author

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){
Copy link
Collaborator Author

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">
Copy link
Member

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.

Copy link
Member

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?

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

Comment on lines +1 to +36
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"))
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, TIL.

@MarcoSignoretto MarcoSignoretto merged commit ac42921 into generate-mocks Aug 24, 2021
@MarcoSignoretto MarcoSignoretto deleted the decouple_plugin branch October 17, 2021 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants