Java Code Examples for org.apache.maven.shared.model.fileset.FileSet#setDirectory()
The following examples show how to use
org.apache.maven.shared.model.fileset.FileSet#setDirectory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AggregationTest.java From wisdom with Apache License 2.0 | 6 votes |
@Test public void testOrderOfFileSet() { FileSet fs = new FileSet(); fs.setDirectory("target/test-classes/aggregation"); fs.setIncludes( ImmutableList.of( "core/the-first-to-aggregate.js", "core/**/*.js", "utils/**/*.js", "plugins/**/*uses*.js", "plugins/**/*.js" ) ); Aggregation aggregation = new Aggregation(); aggregation.setFileSets(ImmutableList.of(fs)); final Collection<File> included = aggregation.getSelectedFiles(new File("target")); assertThat(included).hasSize(5); // Check order assertThat(Iterables.get(included, 0).getAbsolutePath()).isEqualToIgnoringCase( new File("target/test-classes/aggregation/core/the-first-to-aggregate.js").getAbsolutePath()); assertThat(Iterables.get(included, 1).getAbsolutePath()).isEqualToIgnoringCase( new File("target/test-classes/aggregation/core/a.js").getAbsolutePath()); assertThat(Iterables.get(included, 4).getAbsolutePath()).isEqualToIgnoringCase( new File("target/test-classes/aggregation/plugins/another-file.js").getAbsolutePath()); }
Example 2
Source File: AggregationTest.java From wisdom with Apache License 2.0 | 6 votes |
@Test public void testExcludes() { FileSet fs = new FileSet(); fs.setDirectory("target/test-classes/aggregation"); fs.setIncludes( ImmutableList.of( "core/the-first-to-aggregate.js", "core/**/*.js", "utils/**/*.js", "plugins/**/*uses*.js", "plugins/**/*.js" ) ); fs.setExcludes( ImmutableList.of("**/another-file*") ); Aggregation aggregation = new Aggregation(); aggregation.setFileSets(ImmutableList.of(fs)); final Collection<File> included = aggregation.getSelectedFiles(new File("target")); assertThat(included).hasSize(4); assertThat(Iterables.get(included, 0).getAbsolutePath()).isEqualToIgnoringCase( new File("target/test-classes/aggregation/core/the-first-to-aggregate.js").getAbsolutePath()); assertThat(Iterables.get(included, 1).getAbsolutePath()).isEqualToIgnoringCase( new File("target/test-classes/aggregation/core/a.js").getAbsolutePath()); }
Example 3
Source File: WebJarPackagerTest.java From wisdom with Apache License 2.0 | 6 votes |
@Test public void testIncludesCustomization() 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.0"); when(packager.project.getBasedir()).thenReturn(fake); packager.buildDirectory = new File("target/junk"); copy(); packager.webjar = new WebJar(); FileSet set = new FileSet(); set.setDirectory(new File(classes, "assets").getAbsolutePath()); set.setIncludes(ImmutableList.of("**/coffee/*")); packager.webjar.setFileset(set); packager.execute(); final File wj = new File(packager.buildDirectory, "test-1.0-webjar.jar"); assertThat(wj).isFile(); JarFile jar = new JarFile(wj); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/missing")).isNull(); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/coffee/script.coffee")).isNotNull(); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/less/style.less")).isNull(); }
Example 4
Source File: WebJarPackagerTest.java From wisdom with Apache License 2.0 | 6 votes |
@Test public void testExcludesCustomization() 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.0"); when(packager.project.getBasedir()).thenReturn(fake); packager.buildDirectory = new File("target/junk"); copy(); packager.webjar = new WebJar(); FileSet set = new FileSet(); set.setDirectory(new File(classes, "assets").getAbsolutePath()); set.setExcludes(ImmutableList.of("**/less/*")); packager.webjar.setFileset(set); packager.execute(); final File wj = new File(packager.buildDirectory, "test-1.0-webjar.jar"); assertThat(wj).isFile(); JarFile jar = new JarFile(wj); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/missing")).isNull(); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/coffee/script.coffee")).isNotNull(); assertThat(jar.getEntry(WebJarPackager.ROOT + "test/1.0/less/style.less")).isNull(); }
Example 5
Source File: AggregationTest.java From wisdom with Apache License 2.0 | 5 votes |
@Test public void testOrderOfFileSets() { FileSet fs1 = new FileSet(); fs1.setDirectory("target/test-classes/aggregation"); fs1.setIncludes( ImmutableList.of( "core/the-first-to-aggregate.js", "core/**/*.js", "utils/**/*.js", "plugins/**/*uses*.js", "plugins/**/*.js" ) ); FileSet fs2 = new FileSet(); fs2.setDirectory("target/test-classes/aggregation"); fs2.setIncludes( ImmutableList.of( "utils/**/*.js", "plugins/**/*uses*.js", "plugins/**/*.js" ) ); Aggregation aggregation = new Aggregation(); aggregation.setFileSets(ImmutableList.of(fs1, fs2)); final Collection<File> included = aggregation.getSelectedFiles(new File("target")); assertThat(included).hasSize(5); // Check order assertThat(Iterables.get(included, 0).getAbsolutePath()).isEqualToIgnoringCase( new File("target/test-classes/aggregation/core/the-first-to-aggregate.js").getAbsolutePath()); assertThat(Iterables.get(included, 1).getAbsolutePath()).isEqualToIgnoringCase( new File("target/test-classes/aggregation/core/a.js").getAbsolutePath()); assertThat(Iterables.get(included, 4).getAbsolutePath()).isEqualToIgnoringCase( new File("target/test-classes/aggregation/plugins/another-file.js").getAbsolutePath()); }
Example 6
Source File: WebJarPackager.java From wisdom with Apache License 2.0 | 4 votes |
@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); } }