-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: main
Are you sure you want to change the base?
Changes from 12 commits
3530454
27af76e
facccaf
80ef379
84cfaf5
abc9363
51fe379
f7d7695
c1d21e4
6e40d31
2964e78
3188085
126924f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
|
Author
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. moved to |
||
| } | ||
|
|
||
| @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(); | ||
|
Author
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 |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.