Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Filtering now works, but is not configurable yet (instead it is alway…

…s on).
  • Loading branch information...
commit d2c347d8970af111c6f7eb0a0bc29f1a5b2b9a54 1 parent cabf322
@nawroth nawroth authored
Showing with 20 additions and 9 deletions.
  1. +20 −9 src/main/java/org/neo4j/build/plugins/docs/DocsAssembler.java
View
29 src/main/java/org/neo4j/build/plugins/docs/DocsAssembler.java
@@ -26,6 +26,7 @@
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -101,12 +102,18 @@ private File doAssembly( final List<String> sourceDirectories )
{
List<File> dirs = getDirectories( sourceDirectories );
+ File destFile = null;
if ( resourceFiltering != null )
{
- filterResources( dirs );
- // TODO in this case, the filter target is the only one to zip.
+ File target = new File( new File( project.getBuild()
+ .getDirectory() ), "filtered-docs" );
+ filterResources( dirs, target );
+ destFile = createArchive( Collections.singletonList( target ) );
+ }
+ else
+ {
+ destFile = createArchive( dirs );
}
- File destFile = createArchive( dirs );
projectHelper.attachArtifact( project, "jar", "docs", destFile );
@@ -164,14 +171,17 @@ private File createArchive( final List<File> directories )
return destFile;
}
- private void filterResources( final List<File> directories )
+ private void filterResources( final List<File> directories, File targetDir )
{
- System.out.println( "lets filter resources ..." );
+ getLog().info( "Filter target: " + targetDir );
+ int baseDirLength = project.getBasedir()
+ .getAbsolutePath()
+ .length() + 1;
MavenResourcesExecution resourcesExecution = new MavenResourcesExecution();
resourcesExecution.setEncoding( "UTF-8" );
resourcesExecution.setMavenProject( project );
- resourcesExecution.setOutputDirectory( new File( "target/gendocs" ) );
- resourcesExecution.setResourcesBaseDirectory( new File( "target/x" ) );
+ resourcesExecution.setOutputDirectory( targetDir );
+ resourcesExecution.setResourcesBaseDirectory( project.getBasedir() );
resourcesExecution.addFilterWrapper( new FileUtils.FilterWrapper()
{
@Override
@@ -184,8 +194,9 @@ public Reader getReader( final Reader reader )
for ( File dir : directories )
{
Resource resource = new Resource();
- resource.setDirectory( dir.getAbsolutePath() );
- resource.setTargetPath( "target" );
+ resource.setDirectory( dir.getAbsolutePath()
+ .substring( baseDirLength ) );
+ getLog().info( "Adding source directory: " + dir );
resource.setFiltering( true );
resources.add( resource );
}
Please sign in to comment.
Something went wrong with that request. Please try again.