@Test public void testProcessingOfStylesheets() throws MojoFailureException, MojoExecutionException, IOException { cleanup(); final File destDir = new File(mojo.buildDirectory, "classes/assets/css"); destDir.mkdirs(); FileUtils.copyFileToDirectory(new File(mojo.basedir, "src/main/resources/assets/css/site.css"), destDir); mojo.stylesheets = new Stylesheets(); Aggregation aggregation1 = new Aggregation(); aggregation1.setFiles(ImmutableList.of( "less/style.css", "css/site.css" )); aggregation1.setOutput("aggregation1.css"); Aggregation aggregation2 = new Aggregation(); aggregation2.setFiles(ImmutableList.of( "css/site.css" )); mojo.stylesheets.setAggregations(ImmutableList.of(aggregation1, aggregation2)); less.execute(); mojo.execute(); File agg = new File(FAKE_PROJECT_TARGET, "classes/assets/test-artifact-min.css"); assertThat(agg).isFile(); assertThat(FileUtils.readFileToString(agg)) .contains("h1{color:red}") .doesNotContain(".box"); File agg1 = new File(FAKE_PROJECT_TARGET, "classes/assets/aggregation1.css"); assertThat(agg1).isFile(); assertThat(FileUtils.readFileToString(agg1)) .contains("h1{color:red}") .contains(".box"); }
@Override public void execute() throws MojoExecutionException { if (skipCleanCSS) { getLog().debug("Skipping CSS minification"); removeFromWatching(); return; } cleancss = NPM.npm(this, CLEANCSS_NPM_NAME, cleanCssVersion); getLog().info("Clean CSS version: " + cleanCssVersion); if (stylesheets == null) { getLog().info("No 'stylesheets' processing configuration, minifying all '.css' files individually"); for (File file : getResources(getExtensions())) { try { process(file); } catch (WatchingException e) { throw new MojoExecutionException(e.getMessage(), e); } } } else { process(stylesheets); } }
CSSMinifierMojo extends AbstractWisdomWatcherMojo { @Override public void execute() throws MojoExecutionException { if (skipCleanCSS) { getLog().debug("Skipping CSS minification"); removeFromWatching(); return; } cleancss = NPM.npm(this, CLEANCSS_NPM_NAME, cleanCssVersion); getLog().info("Clean CSS version: " + cleanCssVersion); if (stylesheets == null) { getLog().info("No 'stylesheets' processing configuration, minifying all '.css' files individually"); for (File file : getResources(getExtensions())) { try { process(file); } catch (WatchingException e) { throw new MojoExecutionException(e.getMessage(), e); } } } else { process(stylesheets); } } }
CSSMinifierMojo extends AbstractWisdomWatcherMojo { @Override public void execute() throws MojoExecutionException { if (skipCleanCSS) { getLog().debug("Skipping CSS minification"); removeFromWatching(); return; } cleancss = NPM.npm(this, CLEANCSS_NPM_NAME, cleanCssVersion); getLog().info("Clean CSS version: " + cleanCssVersion); if (stylesheets == null) { getLog().info("No 'stylesheets' processing configuration, minifying all '.css' files individually"); for (File file : getResources(getExtensions())) { try { process(file); } catch (WatchingException e) { throw new MojoExecutionException(e.getMessage(), e); } } } else { process(stylesheets); } }  }
CSSMinifierMojo extends AbstractWisdomWatcherMojo { @Override public void execute() throws MojoExecutionException { if (skipCleanCSS) { getLog().debug("Skipping CSS minification"); removeFromWatching(); return; } cleancss = NPM.npm(this, CLEANCSS_NPM_NAME, cleanCssVersion); getLog().info("Clean CSS version: " + cleanCssVersion); if (stylesheets == null) { getLog().info("No 'stylesheets' processing configuration, minifying all '.css' files individually"); for (File file : getResources(getExtensions())) { try { process(file); } catch (WatchingException e) { throw new MojoExecutionException(e.getMessage(), e); } } } else { process(stylesheets); } }  @Override void execute(); @Override boolean accept(File file); boolean isNotMinified(File file); @Override boolean fileCreated(File file); @Override boolean fileUpdated(File file); @Override boolean fileDeleted(File file); File getFilteredVersion(File input); }
CSSMinifierMojo extends AbstractWisdomWatcherMojo { @Override public void execute() throws MojoExecutionException { if (skipCleanCSS) { getLog().debug("Skipping CSS minification"); removeFromWatching(); return; } cleancss = NPM.npm(this, CLEANCSS_NPM_NAME, cleanCssVersion); getLog().info("Clean CSS version: " + cleanCssVersion); if (stylesheets == null) { getLog().info("No 'stylesheets' processing configuration, minifying all '.css' files individually"); for (File file : getResources(getExtensions())) { try { process(file); } catch (WatchingException e) { throw new MojoExecutionException(e.getMessage(), e); } } } else { process(stylesheets); } }  @Override void execute(); @Override boolean accept(File file); boolean isNotMinified(File file); @Override boolean fileCreated(File file); @Override boolean fileUpdated(File file); @Override boolean fileDeleted(File file); File getFilteredVersion(File input); static final String CLEANCSS_NPM_NAME; static final String CLEANCSS_NPM_VERSION; @Parameter(defaultValue = "${skipCleanCSS}")
    public boolean skipCleanCSS; @Parameter(defaultValue = "-min")
    public String cssMinifierSuffix; }