Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4 from jussimalinen/invoker-it-tests

Integration tests based on maven-invoker-plugin
  • Loading branch information...
commit 17260d3451b61ca448b8d2ff0eaca011f1abd159 2 parents c963da0 + b657ef8
@mcculls mcculls authored
View
1  .gitignore
@@ -2,3 +2,4 @@ target
.project
.classpath
.settings
+.DS_Store
View
22 pom.xml
@@ -103,6 +103,28 @@
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
</plugin>
+ <plugin>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>1.7</version>
+ <configuration>
+ <projectsDirectory>src/it</projectsDirectory>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <postBuildHookScript>verify.bsh</postBuildHookScript>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
View
BIN  src/it/empty_dirs/example_with_empty_dir.jar
Binary file not shown
View
50 src/it/empty_dirs/pom.xml
@@ -0,0 +1,50 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.test</groupId>
+ <artifactId>mytest</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>mytest</name>
+ <url>http://maven.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>jarjar-maven-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>jarjar</goal>
+ </goals>
+ <configuration>
+ <input>example_with_empty_dir.jar</input>
+ <output>target/out.jar</output>
+ <includes>
+ <include>junit:junit</include>
+ </includes>
+ <rules>
+ <rule>
+ <pattern>junit.**</pattern>
+ <result>com.test.@0</result>
+ </rule>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
36 src/it/empty_dirs/verify.bsh
@@ -0,0 +1,36 @@
+import java.io.*;
+import java.util.jar.JarFile;
+
+JarFile getFile() {
+ File file = new File(basedir, "target/out.jar" );
+ if ( !file.isFile() ) {
+ throw new FileNotFoundException( "Could not find generated JAR: " + file );
+ }
+ return new JarFile(file);
+}
+
+mustNotExist(JarFile file, String path) {
+ if (file.getEntry(path) != null)
+ throw new RuntimeException(path + " should not be in "+file.getName());
+}
+
+mustExist(JarFile file, String path) {
+ if (file.getEntry(path) == null)
+ throw new RuntimeException(path + " should be in "+file.getName());
+}
+
+verifyNoEmptyDir() {
+ mustNotExist(getFile(), "test/empty/");
+}
+
+verifyDirWithFilesIsPresent() {
+ mustExist(getFile(), "test/has_file/");
+}
+
+testDirectoriesCreatedByRulesAreIncluded() {
+ mustExist(getFile(), "com/test/junit/");
+}
+
+verifyNoEmptyDir();
+verifyDirWithFilesIsPresent();
+testDirectoriesCreatedByRulesAreIncluded();
View
1  src/main/java/com/tonicsystems/jarjar/JarJarMojo.java
@@ -180,7 +180,6 @@ public void execute()
final Archiver archiver = archiverManager.getArchiver( "zip" );
archiver.setDestFile( uberZip );
- archiver.setIncludeEmptyDirs( false );
if ( inputFile.isDirectory() )
{
Please sign in to comment.
Something went wrong with that request. Please try again.