-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented abstract model of the plugin deployement
Implemented the default plugin, task and action classes to develope the plugin.
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
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
19 changes: 19 additions & 0 deletions
19
depclean-gradle-plugin/src/main/java/se/kth/depclean/DepCleanGradleAction.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,19 @@ | ||
package se.kth.depclean; | ||
|
||
import lombok.SneakyThrows; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.Project; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
|
||
/** | ||
* Depclean default and only action. | ||
*/ | ||
public class DepCleanGradleAction implements Action<Project> { | ||
|
||
@SneakyThrows | ||
@Override | ||
public void execute(@NotNull Project project) { | ||
// To be continued. | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
depclean-gradle-plugin/src/main/java/se/kth/depclean/DepCleanGradlePlugin.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,34 @@ | ||
package se.kth.depclean; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* This plugin checks the bytecode of a gradle project and configure out whether a dependency | ||
* is used in that project or not. After analysis, it also configures out the source of that | ||
* dependency i.e. whether <br> | ||
* <b>1)</b> It is declared directly in your build.gradle file or, <br> | ||
* <b>2)</b> Inherited from any direct dependency or, <br> | ||
* <b>3)</b> Just a transitive dependency. | ||
*/ | ||
public class DepCleanGradlePlugin implements Plugin<Project> { | ||
|
||
@Override | ||
public void apply(@NotNull Project project) { | ||
// Creating the default task. | ||
createTask(project); | ||
} | ||
|
||
/** | ||
* Creating a task that performs the DepClean default action. | ||
* | ||
* @param project The Gradle project. | ||
*/ | ||
public void createTask(final Project project) { | ||
final String depCleanTaskName = "debloat"; | ||
DepCleanGradleTask task = project.getTasks().create(depCleanTaskName, DepCleanGradleTask.class); | ||
task.setGroup("dependency management"); | ||
task.setDescription("Analyze the project byte-code and configure out the debloated dependencies."); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
depclean-gradle-plugin/src/main/java/se/kth/depclean/DepCleanGradleTask.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,27 @@ | ||
package se.kth.depclean; | ||
|
||
import org.gradle.api.Action; | ||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.TaskAction; | ||
|
||
/** | ||
* Task that configures out the bloated dependencies. | ||
*/ | ||
public class DepCleanGradleTask extends DefaultTask { | ||
|
||
/** | ||
* Action that analyzes the project dependencies and show the results. | ||
*/ | ||
@TaskAction | ||
public void analyzeProject() { | ||
|
||
getProject().getLogger().lifecycle("Starting DepClean dependency analysis"); | ||
|
||
// Applying the only default action on the project and it's sub-projects (if any). | ||
Action<Project> defaultAction = new DepCleanGradleAction(); | ||
getProject().allprojects(defaultAction); | ||
|
||
} | ||
|
||
} |