Skip to content

Commit

Permalink
feat: add skip option to disable plugin execution
Browse files Browse the repository at this point in the history
  • Loading branch information
cleydyr committed Dec 29, 2024
1 parent fb2e068 commit 4f93a97
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/main/java/com/github/cleydyr/maven/plugin/CompileSassMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,20 @@ public CompileSassMojo(
@Parameter
private File cachedFilesDirectory;

/**
* This parameter allows to skip the execution of the plugin.
*/
@Parameter(property = "dart.sass.skip")
private boolean skip;

@Override
public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Skipping execution of the plugin");

return;
}

validateProxyHostSyntax();

verifyDefaultParameters();
Expand Down Expand Up @@ -554,4 +566,8 @@ public boolean isTrace() {
public void setTrace(boolean trace) {
this.trace = trace;
}

public void setSkip(boolean skip) {
this.skip = skip;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ public void testCompileSubfolders() throws Exception {
TestUtil.executeGoal(testDir, "clean");
}

@Test
public void testSkipFlag() throws Exception {
TestUtil.installMainPlugin();

File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/test-project");

TestUtil.executeGoal(testDir, "clean");

TestUtil.executeGoal(testDir, "compile", "-Ddart.sass.skip=true");

Path outputDirPath = Paths.get(testDir.getAbsolutePath(), "target", "static", "styles");

assertFalse(Files.exists(outputDirPath));
}

private static long getFileCount(Path outputDirPath) throws IOException {
long fileCount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ public static void installMainPlugin() throws VerificationException {
verifier.verifyErrorFreeLog();
}

public static void executeGoal(File testDir, String goal) throws VerificationException {
public static void executeGoal(File testDir, String goal, String... additionalCLiArguments)
throws VerificationException {
Verifier verifier = new Verifier(testDir.getAbsolutePath());
verifier.addCliArgument(goal);

for (String arg : additionalCLiArguments) {
verifier.addCliArgument(arg);
}

verifier.execute();
verifier.verifyErrorFreeLog();
}
Expand Down

0 comments on commit 4f93a97

Please # to comment.