Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Configuration cleanup, better error handling, enabled dogfooding.

  • Loading branch information...
commit 37458f2a0c1d744e9fd1f6dca98225cea057e2b0 1 parent 3d0e1b6
Anders Nawroth nawroth authored
48 pom.xml
View
@@ -47,30 +47,19 @@
</sourceDirectories>
</configuration>
-->
- <!--
- <configuration>
- <executions>
- <execution>
- <id>assemble-docs</id>
- <phase>package</phase>
- <goals><goal>assemble</goal></goals>
- </execution>
- </executions>
- </configuration>
- -->
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- </plugin>
- <plugin>
<artifactId>docs-maven-plugin</artifactId>
<groupId>org.neo4j.build.plugins</groupId>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
@@ -160,4 +149,33 @@
</dependency>
</dependencies>
</dependencyManagement>
+
+ <profiles>
+ <profile>
+ <id>enable-dogfooding-plugin</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ <property>
+ <name>dogfood</name>
+ </property>
+ </activation>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>docs-maven-plugin</artifactId>
+ <groupId>org.neo4j.build.plugins</groupId>
+ <executions>
+ <execution>
+ <id>assemble-docs</id>
+ <goals><goal>assemble</goal></goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+ </profiles>
+
</project>
1  src/main/java/org/neo4j/build/plugins/docs/AssembleMojo.java
View
@@ -32,6 +32,7 @@
* Goal which assembles docs.
*
* @goal assemble
+ * @phase package
*/
public class AssembleMojo extends AbstractMojo
{
41 src/main/java/org/neo4j/build/plugins/docs/DocsAssembler.java
View
@@ -29,6 +29,7 @@
import java.util.Collections;
import java.util.List;
import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
import java.util.zip.ZipOutputStream;
import org.apache.maven.execution.MavenSession;
@@ -44,11 +45,13 @@
public final class DocsAssembler
{
- private static final String TYPE = "jar";
+ private static final String DOCS_DIRNAME = "docs";
private static final String CLASSIFIER = "docs";
- private static final int BUFFER_SIZE = 1024;
+ private static final String TYPE = "jar";
+
+ private static final int BUFFER_SIZE = 4096;
private int currentBaseDirPathLength;
@@ -62,6 +65,8 @@
private MavenSession session;
+ private ZipOutputStream zipOut;
+
private Log getLog()
{
return log;
@@ -132,7 +137,7 @@ private File createArchive( final List<File> directories )
}
FileOutputStream fileOut = null;
- ZipOutputStream zipOut = null;
+ zipOut = null;
try
{
fileOut = new FileOutputStream( destFile );
@@ -143,7 +148,7 @@ private File createArchive( final List<File> directories )
currentBaseDirPathLength = dir.getAbsolutePath()
.length();
getLog().info( "Adding source directory: " + dir );
- zipDirectory( zipOut, dir );
+ zipDirectory( dir );
}
}
catch ( FileNotFoundException e )
@@ -158,6 +163,17 @@ private File createArchive( final List<File> directories )
{
zipOut.close();
}
+ catch ( ZipException e )
+ {
+ if ( "ZIP file must have at least one entry".equals( e.getMessage() ) )
+ {
+ getLog().warn( "There were no docs to assemble." );
+ }
+ else
+ {
+ getLog().error( e );
+ }
+ }
catch ( IOException e )
{
getLog().error( e );
@@ -186,8 +202,7 @@ private void filterResources( final List<File> directories, File targetDir )
MavenResourcesExecution resourcesExecution = new MavenResourcesExecution(
resources, targetDir, project, "UTF-8",
- Collections.<Object>emptyList(), Collections.emptyList(),
- session );
+ Collections.emptyList(), Collections.emptyList(), session );
resourcesExecution.setResourcesBaseDirectory( project.getBasedir() );
resourcesExecution.addFilterWrapper( new FileUtils.FilterWrapper()
{
@@ -207,8 +222,7 @@ public Reader getReader( final Reader reader )
}
}
- private void zipDirectory( final ZipOutputStream zipOut, final File dir )
- throws MojoExecutionException
+ private void zipDirectory( final File dir ) throws MojoExecutionException
{
byte[] buf = new byte[BUFFER_SIZE];
@@ -216,7 +230,7 @@ private void zipDirectory( final ZipOutputStream zipOut, final File dir )
{
if ( file.isDirectory() )
{
- zipDirectory( zipOut, file );
+ zipDirectory( file );
continue;
}
FileInputStream inFile = null;
@@ -265,9 +279,9 @@ private void zipDirectory( final ZipOutputStream zipOut, final File dir )
// add default directories
// ./src/docs and ./target/docs
addDirectory( new File( new File( project.getBasedir(), "src" ),
- CLASSIFIER ), directories );
+ DOCS_DIRNAME ), directories );
addDirectory( new File( project.getBuild()
- .getDirectory(), CLASSIFIER ), directories );
+ .getDirectory(), DOCS_DIRNAME ), directories );
}
else
{
@@ -287,6 +301,11 @@ private void addDirectory( final File dir, final List<File> directories )
getLog().info( "Skipping, does not exist: " + dir );
return;
}
+ if ( dir.listFiles().length == 0 )
+ {
+ getLog().info( "Skipping, is empty: " + dir );
+ return;
+ }
if ( !dir.isDirectory() )
{
throw new MojoExecutionException( "Not a directory: "
Please sign in to comment.
Something went wrong with that request. Please try again.