Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from jussimalinen/invoker-it-tests
Browse files Browse the repository at this point in the history
Integration tests based on maven-invoker-plugin
  • Loading branch information
mcculls committed Oct 9, 2012
2 parents c963da0 + b657ef8 commit 17260d3
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target
.project
.classpath
.settings
.DS_Store
22 changes: 22 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Binary file added src/it/empty_dirs/example_with_empty_dir.jar
Binary file not shown.
50 changes: 50 additions & 0 deletions src/it/empty_dirs/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
36 changes: 36 additions & 0 deletions src/it/empty_dirs/verify.bsh
Original file line number Diff line number Diff line change
@@ -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();
1 change: 0 additions & 1 deletion src/main/java/com/tonicsystems/jarjar/JarJarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ public void execute()
final Archiver archiver = archiverManager.getArchiver( "zip" );

archiver.setDestFile( uberZip );
archiver.setIncludeEmptyDirs( false );

if ( inputFile.isDirectory() )
{
Expand Down

0 comments on commit 17260d3

Please sign in to comment.