-
Notifications
You must be signed in to change notification settings - Fork 0
Add Spotless configuration & introduce test plugin #2
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
Open
gpunto
wants to merge
6
commits into
develop
Choose a base branch
from
spotless
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+416
−14
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b1f581e
Add Spotless configuration to plugins
gpunto d2df365
Preselect minor in release workflow
gpunto 61f00d8
Introduce Android test Stream plugin
gpunto f1698c1
Update readme
gpunto 666a385
Bump publish plugin
gpunto a105268
Group Spotless-specific configuration
gpunto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
66 changes: 66 additions & 0 deletions
66
plugin/src/main/kotlin/io/getstream/android/GenerateLicenseFileTask.kt
This file contains hidden or 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,66 @@ | ||
| /* | ||
| * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-build-conventions-android/blob/main/LICENSE | ||
| * | ||
| * 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 io.getstream.android | ||
|
|
||
| import java.io.BufferedReader | ||
| import org.gradle.api.DefaultTask | ||
| import org.gradle.api.file.ConfigurableFileCollection | ||
| import org.gradle.api.file.RegularFileProperty | ||
| import org.gradle.api.provider.Property | ||
| import org.gradle.api.tasks.CacheableTask | ||
| import org.gradle.api.tasks.Classpath | ||
| import org.gradle.api.tasks.Input | ||
| import org.gradle.api.tasks.OutputFile | ||
| import org.gradle.api.tasks.TaskAction | ||
|
|
||
| /** | ||
| * Task that generates license header files from templates bundled in the plugin. | ||
| * | ||
| * This task uses [@Classpath] to track the plugin JAR that contains the template resources. When | ||
| * the plugin is updated with new template content, Gradle will automatically detect the change and | ||
| * regenerate the license files. | ||
| */ | ||
| @CacheableTask | ||
| abstract class GenerateLicenseFileTask : DefaultTask() { | ||
| @get:Input abstract val repositoryName: Property<String> | ||
|
|
||
| @get:Input abstract val templateName: Property<String> | ||
|
|
||
| /** | ||
| * The classpath containing the plugin resources (the plugin JAR itself). Used to track changes | ||
| * to the template files so the task is re-run. | ||
| */ | ||
| @get:Classpath abstract val pluginClasspath: ConfigurableFileCollection | ||
|
|
||
| @get:OutputFile abstract val outputFile: RegularFileProperty | ||
|
|
||
| @TaskAction | ||
| fun generate() { | ||
| val templateContent = | ||
| javaClass.classLoader | ||
| .getResourceAsStream(templateName.get()) | ||
| ?.bufferedReader() | ||
| ?.use(BufferedReader::readText) | ||
| ?: throw IllegalStateException( | ||
| "Could not find bundled ${templateName.get()} resource" | ||
| ) | ||
|
|
||
| outputFile | ||
| .get() | ||
| .asFile | ||
| .writeText(templateContent.replace("\$PROJECT", repositoryName.get())) | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
plugin/src/main/kotlin/io/getstream/android/StreamConventionExtensions.kt
This file contains hidden or 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,54 @@ | ||
| /* | ||
| * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-build-conventions-android/blob/main/LICENSE | ||
| * | ||
| * 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 io.getstream.android | ||
|
|
||
| import io.getstream.android.spotless.SpotlessOptions | ||
| import javax.inject.Inject | ||
| import org.gradle.api.Action | ||
| import org.gradle.api.Project | ||
| import org.gradle.api.model.ObjectFactory | ||
| import org.gradle.api.provider.Property | ||
| import org.gradle.kotlin.dsl.create | ||
| import org.gradle.kotlin.dsl.findByType | ||
| import org.gradle.kotlin.dsl.property | ||
|
|
||
| /** | ||
| * Extension for configuring Stream project-wide settings. Apply the `io.getstream.project` plugin | ||
| * to the root project to use this extension. | ||
| */ | ||
| abstract class StreamProjectExtension | ||
| @Inject | ||
| constructor(project: Project, objects: ObjectFactory) { | ||
|
|
||
| /** The repository name used for inferring the repository URL. Example: "stream-core-android" */ | ||
| val repositoryName: Property<String> = | ||
| objects.property<String>().convention(project.provider { project.rootProject.name }) | ||
|
|
||
| /** Spotless formatting configuration */ | ||
| val spotless: SpotlessOptions = objects.newInstance(SpotlessOptions::class.java) | ||
|
|
||
| /** Configure Spotless formatting */ | ||
| fun spotless(action: Action<SpotlessOptions>) = action.execute(spotless) | ||
| } | ||
|
|
||
| internal fun Project.createProjectExtension(): StreamProjectExtension = | ||
| extensions.create<StreamProjectExtension>("streamProject") | ||
|
|
||
| internal fun Project.requireStreamProjectExtension(): StreamProjectExtension = | ||
| requireNotNull(rootProject.extensions.findByType<StreamProjectExtension>()) { | ||
| "${StreamProjectExtension::class.simpleName} not found. " + | ||
| "Apply the io.getstream.project plugin to the root project" | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Introducing this too as we use
com.android.testin chat & video