-
Notifications
You must be signed in to change notification settings - Fork 174
print help on error task usage #76
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| package=co.com.bancolombia | ||
| systemProp.version=1.6.4 | ||
| systemProp.version=1.6.5 |
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
38 changes: 38 additions & 0 deletions
38
src/main/java/co/com/bancolombia/task/CleanArchitectureDefaultTask.java
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,38 @@ | ||
| package co.com.bancolombia.task; | ||
|
|
||
| import co.com.bancolombia.factory.ModuleBuilder; | ||
| import org.gradle.api.DefaultTask; | ||
| import org.gradle.api.Task; | ||
| import org.gradle.api.internal.tasks.options.OptionReader; | ||
| import org.gradle.api.logging.Logger; | ||
| import org.gradle.configuration.TaskDetailPrinter; | ||
| import org.gradle.execution.TaskSelector; | ||
| import org.gradle.internal.logging.text.StyledTextOutput; | ||
| import org.gradle.internal.logging.text.StyledTextOutputFactory; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| public class CleanArchitectureDefaultTask extends DefaultTask { | ||
| protected final ModuleBuilder builder = new ModuleBuilder(getProject()); | ||
| protected final Logger logger = getProject().getLogger(); | ||
|
|
||
| protected void printHelp() { | ||
| StyledTextOutput output = this.getTextOutputFactory().create(CleanArchitectureDefaultTask.class); | ||
| final Task task = this; | ||
| TaskSelector.TaskSelection selection = new TaskSelector.TaskSelection(getPath(), getName(), | ||
| collection -> collection.add(task)); | ||
| OptionReader optionReader = this.getOptionReader(); | ||
| TaskDetailPrinter taskDetailPrinter = new TaskDetailPrinter(getName(), selection, optionReader); | ||
| taskDetailPrinter.print(output); | ||
| } | ||
|
|
||
| @Inject | ||
| protected StyledTextOutputFactory getTextOutputFactory() { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Inject | ||
| protected OptionReader getOptionReader() { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
| } |
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
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
71 changes: 71 additions & 0 deletions
71
src/test/java/co/com/bancolombia/task/CleanArchitectureDefaultTaskTest.java
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,71 @@ | ||
| package co.com.bancolombia.task; | ||
|
|
||
| import org.gradle.api.Project; | ||
| import org.gradle.api.internal.tasks.options.OptionDescriptor; | ||
| import org.gradle.api.internal.tasks.options.OptionReader; | ||
| import org.gradle.internal.logging.text.StyledTextOutputFactory; | ||
| import org.gradle.testfixtures.ProjectBuilder; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| import java.io.File; | ||
| import java.util.List; | ||
|
|
||
| import static org.junit.Assert.*; | ||
|
|
||
| public class CleanArchitectureDefaultTaskTest { | ||
| private Project project; | ||
|
|
||
| @Before | ||
| public void setup() { | ||
| project = ProjectBuilder.builder() | ||
| .withName("cleanArchitecture") | ||
| .withProjectDir(new File("build/unitTest")) | ||
| .build(); | ||
|
|
||
| project.getTasks().create("dm", DeleteModuleTask.class); | ||
| project.getTasks().create("cadt", CleanArchitectureDefaultTask.class); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldGetTaskDescriptor() { | ||
| // Arrange | ||
| CleanArchitectureDefaultTask task = (CleanArchitectureDefaultTask) project.getTasks().getByName("cadt"); | ||
| // Act | ||
| OptionReader reader = task.getOptionReader(); | ||
| // Assert | ||
| assertTrue(reader.getOptions(task).isEmpty()); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldGetTaskDescriptorWithOptions() { | ||
| // Arrange | ||
| CleanArchitectureDefaultTask task = (CleanArchitectureDefaultTask) project.getTasks().getByName("dm"); | ||
| // Act | ||
| OptionReader reader = task.getOptionReader(); | ||
| // Assert | ||
| List<OptionDescriptor> list = reader.getOptions(task); | ||
| assertEquals(1, list.size()); | ||
| assertEquals("module", list.get(0).getName()); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldGetTextOutputFactory() { | ||
| // Arrange | ||
| CleanArchitectureDefaultTask task = (CleanArchitectureDefaultTask) project.getTasks().getByName("dm"); | ||
| // Act | ||
| StyledTextOutputFactory factory = task.getTextOutputFactory(); | ||
| // Assert | ||
| assertNotNull(factory); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldPrintHelp() { | ||
| // Arrange | ||
| CleanArchitectureDefaultTask task = (CleanArchitectureDefaultTask) project.getTasks().getByName("dm"); | ||
| // Act | ||
| task.printHelp(); | ||
| // Assert | ||
| assertNotNull(task.getTextOutputFactory()); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.