Skip to content

Commit

Permalink
Implemented abstract model of the plugin deployement
Browse files Browse the repository at this point in the history
Implemented the default plugin, task and action classes to develope the plugin.
  • Loading branch information
ABHAY0O7 committed Jul 27, 2021
1 parent 44f90ea commit 4c00060
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions depclean-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repositories {
dependencies {
implementation(gradleApi())
implementation('se.kth.castor:depclean-core:2.0.2-SNAPSHOT')
implementation('se.kth.castor:depclean-maven-plugin:2.0.2-SNAPSHOT')
compileOnly('org.projectlombok:lombok:1.18.20')
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
Expand Down
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.
}
}
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.");
}
}
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);

}

}

0 comments on commit 4c00060

Please sign in to comment.