@Test public void testDefaultPackaging() throws MojoExecutionException, IOException { WebJarPackager packager = new WebJarPackager(); packager.project = mock(MavenProject.class); packager.projectHelper = mock(MavenProjectHelper.class); when(packager.project.getArtifactId()).thenReturn("test"); when(packager.project.getVersion()).thenReturn("1.1"); when(packager.project.getBasedir()).thenReturn(fake); packager.buildDirectory = new File("target/junk"); copy(); packager.packageWebJar = true; packager.deployWebJarToWisdom = true; packager.execute(); final File wj = new File(packager.buildDirectory, "test-1.1-webjar.jar"); assertThat(wj).isFile(); JarFile jar = new JarFile(wj); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.1/less/style.less")).isNotNull(); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.1/missing")).isNull(); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.1/coffee/script.coffee")).isNotNull(); Attributes attributes = jar.getManifest().getMainAttributes(); assertThat(attributes.getValue("Webjar-Name")).isEqualTo("test"); assertThat(attributes.getValue("Webjar-Version")).isEqualTo("1.1"); }
@Override public void execute() throws MojoExecutionException { if (!enabled()) { removeFromWatching(); return; } FileSet set = new FileSet(); set.setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); if (webjar == null) { webjar = new WebJar(project.getArtifactId(), project.getVersion(), "webjar", set); } else { if (webjar.getFileset() == null) { webjar.setFileset(set); } else if (webjar.getFileset().getDirectory() == null) { getLog().info("No directory define in the webjar fileset - use the AssetOutputDirectory"); webjar.getFileset().setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); } if (webjar.getName() == null) { webjar.setName(project.getArtifactId()); } if (webjar.getVersion() == null) { webjar.setVersion(project.getVersion()); } if (webjar.getClassifier() == null) { webjar.setClassifier("webjar"); } } try { File out = process(); if (out != null) { projectHelper.attachArtifact(project, out, webjar.getClassifier()); if (deployWebJarToWisdom) { copyToDestination(out); } } } catch (Exception e) { throw new MojoExecutionException("Failure while building the webjar", e); } }
WebJarPackager extends AbstractWisdomWatcherMojo { @Override public void execute() throws MojoExecutionException { if (!enabled()) { removeFromWatching(); return; } FileSet set = new FileSet(); set.setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); if (webjar == null) { webjar = new WebJar(project.getArtifactId(), project.getVersion(), "webjar", set); } else { if (webjar.getFileset() == null) { webjar.setFileset(set); } else if (webjar.getFileset().getDirectory() == null) { getLog().info("No directory define in the webjar fileset - use the AssetOutputDirectory"); webjar.getFileset().setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); } if (webjar.getName() == null) { webjar.setName(project.getArtifactId()); } if (webjar.getVersion() == null) { webjar.setVersion(project.getVersion()); } if (webjar.getClassifier() == null) { webjar.setClassifier("webjar"); } } try { File out = process(); if (out != null) { projectHelper.attachArtifact(project, out, webjar.getClassifier()); if (deployWebJarToWisdom) { copyToDestination(out); } } } catch (Exception e) { throw new MojoExecutionException("Failure while building the webjar", e); } } }
WebJarPackager extends AbstractWisdomWatcherMojo { @Override public void execute() throws MojoExecutionException { if (!enabled()) { removeFromWatching(); return; } FileSet set = new FileSet(); set.setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); if (webjar == null) { webjar = new WebJar(project.getArtifactId(), project.getVersion(), "webjar", set); } else { if (webjar.getFileset() == null) { webjar.setFileset(set); } else if (webjar.getFileset().getDirectory() == null) { getLog().info("No directory define in the webjar fileset - use the AssetOutputDirectory"); webjar.getFileset().setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); } if (webjar.getName() == null) { webjar.setName(project.getArtifactId()); } if (webjar.getVersion() == null) { webjar.setVersion(project.getVersion()); } if (webjar.getClassifier() == null) { webjar.setClassifier("webjar"); } } try { File out = process(); if (out != null) { projectHelper.attachArtifact(project, out, webjar.getClassifier()); if (deployWebJarToWisdom) { copyToDestination(out); } } } catch (Exception e) { throw new MojoExecutionException("Failure while building the webjar", e); } }  }
WebJarPackager extends AbstractWisdomWatcherMojo { @Override public void execute() throws MojoExecutionException { if (!enabled()) { removeFromWatching(); return; } FileSet set = new FileSet(); set.setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); if (webjar == null) { webjar = new WebJar(project.getArtifactId(), project.getVersion(), "webjar", set); } else { if (webjar.getFileset() == null) { webjar.setFileset(set); } else if (webjar.getFileset().getDirectory() == null) { getLog().info("No directory define in the webjar fileset - use the AssetOutputDirectory"); webjar.getFileset().setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); } if (webjar.getName() == null) { webjar.setName(project.getArtifactId()); } if (webjar.getVersion() == null) { webjar.setVersion(project.getVersion()); } if (webjar.getClassifier() == null) { webjar.setClassifier("webjar"); } } try { File out = process(); if (out != null) { projectHelper.attachArtifact(project, out, webjar.getClassifier()); if (deployWebJarToWisdom) { copyToDestination(out); } } } catch (Exception e) { throw new MojoExecutionException("Failure while building the webjar", e); } }  @Override void execute(); @Override boolean accept(File file); @Override boolean fileCreated(File file); @Override boolean fileUpdated(File file); @Override boolean fileDeleted(File file); }
WebJarPackager extends AbstractWisdomWatcherMojo { @Override public void execute() throws MojoExecutionException { if (!enabled()) { removeFromWatching(); return; } FileSet set = new FileSet(); set.setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); if (webjar == null) { webjar = new WebJar(project.getArtifactId(), project.getVersion(), "webjar", set); } else { if (webjar.getFileset() == null) { webjar.setFileset(set); } else if (webjar.getFileset().getDirectory() == null) { getLog().info("No directory define in the webjar fileset - use the AssetOutputDirectory"); webjar.getFileset().setDirectory(getInternalAssetOutputDirectory().getAbsolutePath()); } if (webjar.getName() == null) { webjar.setName(project.getArtifactId()); } if (webjar.getVersion() == null) { webjar.setVersion(project.getVersion()); } if (webjar.getClassifier() == null) { webjar.setClassifier("webjar"); } } try { File out = process(); if (out != null) { projectHelper.attachArtifact(project, out, webjar.getClassifier()); if (deployWebJarToWisdom) { copyToDestination(out); } } } catch (Exception e) { throw new MojoExecutionException("Failure while building the webjar", e); } }  @Override void execute(); @Override boolean accept(File file); @Override boolean fileCreated(File file); @Override boolean fileUpdated(File file); @Override boolean fileDeleted(File file);  }