-
Notifications
You must be signed in to change notification settings - Fork 174
Task that allows delete existing subproject #68
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
2 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.1 | ||
| systemProp.version=1.6.2 |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/co/com/bancolombia/task/DeleteModuleTask.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,40 @@ | ||
| package co.com.bancolombia.task; | ||
|
|
||
| import co.com.bancolombia.factory.ModuleBuilder; | ||
| import co.com.bancolombia.utils.Utils; | ||
| import org.gradle.api.DefaultTask; | ||
| import org.gradle.api.tasks.TaskAction; | ||
| import org.gradle.api.tasks.options.Option; | ||
| import org.gradle.api.tasks.options.OptionValues; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class DeleteModuleTask extends DefaultTask { | ||
| private final ModuleBuilder builder = new ModuleBuilder(getProject()); | ||
|
|
||
| private String module; | ||
|
|
||
| @Option(option = "module", description = "Set module name to delete") | ||
| public void setModule(String module) { | ||
| this.module = module; | ||
| } | ||
|
|
||
| @OptionValues("module") | ||
| public List<String> getModules() { | ||
| return new ArrayList<>(getProject().getChildProjects().keySet()); | ||
| } | ||
|
|
||
| @TaskAction | ||
| public void deleteModule() throws IOException { | ||
| if (module == null || !getProject().getChildProjects().containsKey(module)) { | ||
| throw new IllegalArgumentException("No valid module name is set, usage: gradle deleteModule --module " | ||
| + Utils.formatTaskOptions(getModules())); | ||
| } | ||
| builder.deleteModule(module); | ||
| builder.removeFromSettings(module); | ||
| builder.removeDependencyFromModule("app-service", "implementation project(':" + module + "')"); | ||
| builder.persist(); | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
| package co.com.bancolombia.utils; | ||
|
|
||
| public interface FileUpdater { | ||
| String update(String content); | ||
| } |
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,8 +1,8 @@ | ||
| rootProject.name = '{{projectName}}' | ||
|
|
||
| include ":app-service" | ||
| include ":model" | ||
| include ":usecase" | ||
| include ':app-service' | ||
| include ':model' | ||
| include ':usecase' | ||
| project(':app-service').projectDir = file('./applications/app-service') | ||
| project(':model').projectDir = file('./domain/model') | ||
| project(':usecase').projectDir = file('./domain/usecase') |
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
79 changes: 79 additions & 0 deletions
79
src/test/java/co/com/bancolombia/task/DeleteModuleTaskTest.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,79 @@ | ||
| package co.com.bancolombia.task; | ||
|
|
||
| import co.com.bancolombia.exceptions.CleanException; | ||
| import co.com.bancolombia.factory.adapters.ModuleFactoryDrivenAdapter; | ||
| import org.gradle.api.Project; | ||
| import org.gradle.testfixtures.ProjectBuilder; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
|
|
||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| public class DeleteModuleTaskTest { | ||
| private DeleteModuleTask task; | ||
|
|
||
| @Before | ||
| public void setup() throws IOException, CleanException { | ||
| Project project = ProjectBuilder.builder() | ||
| .withName("cleanArchitecture") | ||
| .withProjectDir(new File("build/unitTest")) | ||
| .build(); | ||
|
|
||
| project.getTasks().create("ca", GenerateStructureTask.class); | ||
| GenerateStructureTask generateStructureTask = (GenerateStructureTask) project.getTasks().getByName("ca"); | ||
| generateStructureTask.generateStructureTask(); | ||
|
|
||
| ProjectBuilder.builder() | ||
| .withName("app-service") | ||
| .withProjectDir(new File("build/unitTest/applications/app-service")) | ||
| .withParent(project) | ||
| .build(); | ||
|
|
||
| project.getTasks().create("gda", GenerateDrivenAdapterTask.class); | ||
| GenerateDrivenAdapterTask generateDriven = (GenerateDrivenAdapterTask) project.getTasks().getByName("gda"); | ||
| generateDriven.setType(ModuleFactoryDrivenAdapter.DrivenAdapterType.MONGODB); | ||
| generateDriven.generateDrivenAdapterTask(); | ||
|
|
||
| ProjectBuilder.builder() | ||
| .withName("mongo-repository") | ||
| .withProjectDir(new File("build/unitTest/infrastructure/driven-adapters/mongo-repository")) | ||
| .withParent(project) | ||
| .build(); | ||
|
|
||
| assertTrue(new File("build/unitTest/infrastructure/driven-adapters/mongo-repository/build.gradle").exists()); | ||
|
|
||
| project.getTasks().create("test", DeleteModuleTask.class); | ||
| task = (DeleteModuleTask) project.getTasks().getByName("test"); | ||
| } | ||
|
|
||
| // Assert | ||
| @Test(expected = IllegalArgumentException.class) | ||
| public void deleteNullModule() throws IOException { | ||
| // Arrange | ||
| // Act | ||
| task.deleteModule(); | ||
| } | ||
|
|
||
| // Assert | ||
| @Test(expected = IllegalArgumentException.class) | ||
| public void deleteNonExistentModule() throws IOException { | ||
| // Arrange | ||
| task.setModule("non-existent"); | ||
| // Act | ||
| task.deleteModule(); | ||
| } | ||
|
|
||
| @Test | ||
| public void generateEntryPoint() throws IOException { | ||
| // Arrange | ||
| task.setModule("mongo-repository"); | ||
| // Act | ||
| task.deleteModule(); | ||
| // Assert | ||
| assertFalse(new File("build/unitTest/infrastructure/driven-adapters/mongo-repository/build.gradle").exists()); | ||
| } | ||
| } |
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.
it's required?