-
Notifications
You must be signed in to change notification settings - Fork 461
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
Prefer using plugin extensions over deprecated conventions #1618
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cb9433f
Prefer using plugin extensions over deprecated conventions
Goooler 4410531
Reuse getSources logic for Jvm languages
Goooler 1c21d12
Centralize gradle versions so we can remove version-specific workarou…
nedtwigg 1470666
More version centralizing.
nedtwigg 9f49068
Improve the GroovyExtension error message when there is no target and…
nedtwigg 45e078d
Update changelog.
nedtwigg d7ca743
Fix groovy test for new error message.
nedtwigg 91439e5
spotlessApply
nedtwigg 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 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
55 changes: 55 additions & 0 deletions
55
plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JvmLang.java
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,55 @@ | ||
/* | ||
* Copyright 2023 DiffPlug | ||
* | ||
* 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 com.diffplug.gradle.spotless; | ||
|
||
import java.io.File; | ||
import java.util.function.Function; | ||
|
||
import org.gradle.api.GradleException; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.file.FileCollection; | ||
import org.gradle.api.file.SourceDirectorySet; | ||
import org.gradle.api.plugins.JavaPluginConvention; | ||
import org.gradle.api.plugins.JavaPluginExtension; | ||
import org.gradle.api.specs.Spec; | ||
import org.gradle.api.tasks.SourceSet; | ||
import org.gradle.api.tasks.SourceSetContainer; | ||
import org.gradle.util.GradleVersion; | ||
|
||
interface JvmLang { | ||
|
||
default FileCollection getSources(Project project, String message, Function<SourceSet, SourceDirectorySet> sourceSetSourceDirectory, Spec<? super File> filterSpec) { | ||
final SourceSetContainer sourceSets; | ||
FileCollection union = project.files(); | ||
if (GradleVersion.current().compareTo(GradleVersion.version(SpotlessPlugin.VER_GRADLE_javaPluginExtension)) >= 0) { | ||
final JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class); | ||
if (javaPluginExtension == null) { | ||
throw new GradleException(message); | ||
} | ||
sourceSets = javaPluginExtension.getSourceSets(); | ||
} else { | ||
final JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin(JavaPluginConvention.class); | ||
if (javaPluginConvention == null) { | ||
throw new GradleException(message); | ||
} | ||
sourceSets = javaPluginConvention.getSourceSets(); | ||
} | ||
for (SourceSet sourceSet : sourceSets) { | ||
union = union.plus(sourceSetSourceDirectory.apply(sourceSet).filter(filterSpec)); | ||
} | ||
return union; | ||
} | ||
} |
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
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
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.
May need to bump
VER_GRADLE_min
to7.1
in the future, using conventions will start emitting deprecation warnings in Gradle 8.1, and will be removed in the later Gradle 8 versions.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.
Roger. If we are throwing warnings that we can't easily workaround with a version check, then I'm happy to bump the minimum.
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.
@nedtwigg Are you planning to move on Gradle plugin 7? If so can we bump the min Gradle requirement to 7.1 for something like this?
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 thought that this
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JvmLang.java
Lines 37 to 49 in ed88d33
would let us keep
6.1.1
as our min and not emit warnings. But if we are emitting warnings and its very difficult to workaround, then sure I'm okay with bumping the minimum.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.
And 682dcd6.