forked from palantir/gradle-revapi
-
Notifications
You must be signed in to change notification settings - Fork 6
Make gradle-revapi
configuration cache friendly
#13
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
Draft
FinlayRJW
wants to merge
13
commits into
revapi:main
Choose a base branch
from
FinlayRJW:finlayw/configuration-cache
base: main
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.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3530454
messing
27af76e
tidy
facccaf
tidy
80ef379
tests with cc
84cfaf5
Merge branch 'finlayw/test-cc' into finlayw/configuration-cache
abc9363
fix all configuration cache issues and test
51fe379
fix
f7d7695
more abstract
c1d21e4
change function name
6e40d31
be more accurate
2964e78
keep with failure
3188085
final touches
126924f
use released version of plugin testing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,70 +20,57 @@ | |
import java.util.Optional; | ||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.provider.Property; | ||
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.Internal; | ||
import org.gradle.api.tasks.TaskAction; | ||
import org.gradle.api.tasks.options.Option; | ||
import org.revapi.gradle.config.AcceptedBreak; | ||
import org.revapi.gradle.config.GroupNameVersion; | ||
import org.revapi.gradle.config.Justification; | ||
|
||
public class RevapiAcceptBreakTask extends DefaultTask { | ||
public abstract class RevapiAcceptBreakTask extends DefaultTask { | ||
private static final String CODE_OPTION = "code"; | ||
private static final String OLD_OPTION = "old"; | ||
private static final String NEW_OPTION = "new"; | ||
private static final String JUSTIFICATION_OPTION = "justification"; | ||
|
||
private final Property<ConfigManager> configManager = | ||
getProject().getObjects().property(ConfigManager.class); | ||
private final Property<String> code = getProject().getObjects().property(String.class); | ||
private final Property<String> oldElement = getProject().getObjects().property(String.class); | ||
private final Property<String> newElement = getProject().getObjects().property(String.class); | ||
private final Property<Justification> justification = | ||
getProject().getObjects().property(Justification.class); | ||
|
||
public RevapiAcceptBreakTask() { | ||
getOutputs().upToDateWhen(_ignored -> false); | ||
} | ||
|
||
@Internal | ||
final Property<ConfigManager> getConfigManager() { | ||
return configManager; | ||
} | ||
|
||
@Input | ||
@Option(option = CODE_OPTION, description = "Revapi change code") | ||
public final void setCode(String codeString) { | ||
this.code.set(codeString); | ||
} | ||
public abstract Property<String> getCode(); | ||
|
||
@Input | ||
@Option(option = OLD_OPTION, description = "Old API element") | ||
public final void setOldElement(String oldElementString) { | ||
this.oldElement.set(oldElementString); | ||
} | ||
public abstract Property<String> getOldElement(); | ||
|
||
@Input | ||
@Option(option = NEW_OPTION, description = "New API element") | ||
public final void setNewElement(String newElementString) { | ||
this.newElement.set(newElementString); | ||
} | ||
public abstract Property<String> getNewElement(); | ||
|
||
@Input | ||
@Option(option = JUSTIFICATION_OPTION, description = "Justification for why these breaks are ok") | ||
public final void setJustification(String justificationString) { | ||
this.justification.set(Justification.fromString(justificationString)); | ||
} | ||
public abstract Property<String> getJustificationString(); | ||
|
||
@Input | ||
protected abstract Property<GroupNameVersion> getGroupNameVersion(); | ||
|
||
@Internal | ||
protected abstract Property<ConfigManager> getConfigManager(); | ||
|
||
@TaskAction | ||
public final void addVersionOverride() { | ||
ensurePresent(code, CODE_OPTION); | ||
ensurePresent(justification, JUSTIFICATION_OPTION); | ||
ensurePresent(getCode(), CODE_OPTION); | ||
ensurePresent(getJustificationString(), JUSTIFICATION_OPTION); | ||
|
||
configManager | ||
getConfigManager() | ||
.get() | ||
.modifyConfigFile(revapiConfig -> revapiConfig.addAcceptedBreaks( | ||
oldGroupNameVersion(), | ||
getGroupNameVersion().get(), | ||
Collections.singleton(AcceptedBreak.builder() | ||
.code(code.get()) | ||
.oldElement(Optional.ofNullable(oldElement.getOrNull())) | ||
.newElement(Optional.ofNullable(newElement.getOrNull())) | ||
.justification(justification.get()) | ||
.code(getCode().get()) | ||
.oldElement(Optional.ofNullable(getOldElement().getOrNull())) | ||
.newElement(Optional.ofNullable(getNewElement().getOrNull())) | ||
.justification(Justification.fromString( | ||
getJustificationString().get())) | ||
.build()))); | ||
} | ||
|
||
|
@@ -92,8 +79,4 @@ private void ensurePresent(Property<?> prop, String option) { | |
throw new IllegalArgumentException("Please supply the --" + option + " param to this task"); | ||
} | ||
} | ||
|
||
private GroupNameVersion oldGroupNameVersion() { | ||
return getProject().getExtensions().getByType(RevapiExtension.class).oldGroupNameVersion(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the use of |
||
} | ||
} |
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.
moved to
doNotTrackState
inRevapiPlugin.java