Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Integration tests based on maven-invoker-plugin #4

Merged
merged 3 commits into from almost 2 years ago

2 participants

Jussi Malinen Stuart McCulloch
Jussi Malinen

This pull request includes integration tests based on maven-invoker-plugin, and also a change to mojo execution, that sets directories with files as included in jar: 58bbb1c

Stuart McCulloch
Collaborator

Looks good, thanks! I'll add another IT for the leftover entries scenario and fix that without regressing this testcase.

Stuart McCulloch mcculls merged commit 17260d3 into from
Jussi Malinen

Excellent! Thanks!

Do you have any plans/guestimates for the schedule of the next release? (I'm okay with "no idea", just wanted to ask. I think we can use SNAPSHOT to compile our project until then...)

Stuart McCulloch
Collaborator

Definitely before the end of the month, hopefully sooner depending on my spare time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
1  .gitignore
@@ -2,3 +2,4 @@ target
2 2 .project
3 3 .classpath
4 4 .settings
  5 +.DS_Store
22 pom.xml
@@ -103,6 +103,28 @@
103 103 <artifactId>maven-site-plugin</artifactId>
104 104 <version>3.1</version>
105 105 </plugin>
  106 + <plugin>
  107 + <artifactId>maven-invoker-plugin</artifactId>
  108 + <version>1.7</version>
  109 + <configuration>
  110 + <projectsDirectory>src/it</projectsDirectory>
  111 + <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
  112 + <pomIncludes>
  113 + <pomInclude>*/pom.xml</pomInclude>
  114 + </pomIncludes>
  115 + <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
  116 + <postBuildHookScript>verify.bsh</postBuildHookScript>
  117 + </configuration>
  118 + <executions>
  119 + <execution>
  120 + <id>integration-test</id>
  121 + <goals>
  122 + <goal>install</goal>
  123 + <goal>run</goal>
  124 + </goals>
  125 + </execution>
  126 + </executions>
  127 + </plugin>
106 128 </plugins>
107 129 </build>
108 130
BIN  src/it/empty_dirs/example_with_empty_dir.jar
Binary file not shown
50 src/it/empty_dirs/pom.xml
... ... @@ -0,0 +1,50 @@
  1 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3 + <modelVersion>4.0.0</modelVersion>
  4 +
  5 + <groupId>com.test</groupId>
  6 + <artifactId>mytest</artifactId>
  7 + <version>1.0-SNAPSHOT</version>
  8 + <packaging>jar</packaging>
  9 +
  10 + <name>mytest</name>
  11 + <url>http://maven.apache.org</url>
  12 +
  13 + <dependencies>
  14 + <dependency>
  15 + <groupId>junit</groupId>
  16 + <artifactId>junit</artifactId>
  17 + <version>3.8.1</version>
  18 + </dependency>
  19 + </dependencies>
  20 + <build>
  21 + <plugins>
  22 + <plugin>
  23 + <groupId>org.sonatype.plugins</groupId>
  24 + <artifactId>jarjar-maven-plugin</artifactId>
  25 + <version>@project.version@</version>
  26 + <executions>
  27 + <execution>
  28 + <phase>package</phase>
  29 + <goals>
  30 + <goal>jarjar</goal>
  31 + </goals>
  32 + <configuration>
  33 + <input>example_with_empty_dir.jar</input>
  34 + <output>target/out.jar</output>
  35 + <includes>
  36 + <include>junit:junit</include>
  37 + </includes>
  38 + <rules>
  39 + <rule>
  40 + <pattern>junit.**</pattern>
  41 + <result>com.test.@0</result>
  42 + </rule>
  43 + </rules>
  44 + </configuration>
  45 + </execution>
  46 + </executions>
  47 + </plugin>
  48 + </plugins>
  49 + </build>
  50 +</project>
36 src/it/empty_dirs/verify.bsh
... ... @@ -0,0 +1,36 @@
  1 +import java.io.*;
  2 +import java.util.jar.JarFile;
  3 +
  4 +JarFile getFile() {
  5 + File file = new File(basedir, "target/out.jar" );
  6 + if ( !file.isFile() ) {
  7 + throw new FileNotFoundException( "Could not find generated JAR: " + file );
  8 + }
  9 + return new JarFile(file);
  10 +}
  11 +
  12 +mustNotExist(JarFile file, String path) {
  13 + if (file.getEntry(path) != null)
  14 + throw new RuntimeException(path + " should not be in "+file.getName());
  15 +}
  16 +
  17 +mustExist(JarFile file, String path) {
  18 + if (file.getEntry(path) == null)
  19 + throw new RuntimeException(path + " should be in "+file.getName());
  20 +}
  21 +
  22 +verifyNoEmptyDir() {
  23 + mustNotExist(getFile(), "test/empty/");
  24 +}
  25 +
  26 +verifyDirWithFilesIsPresent() {
  27 + mustExist(getFile(), "test/has_file/");
  28 +}
  29 +
  30 +testDirectoriesCreatedByRulesAreIncluded() {
  31 + mustExist(getFile(), "com/test/junit/");
  32 +}
  33 +
  34 +verifyNoEmptyDir();
  35 +verifyDirWithFilesIsPresent();
  36 +testDirectoriesCreatedByRulesAreIncluded();
1  src/main/java/com/tonicsystems/jarjar/JarJarMojo.java
@@ -180,7 +180,6 @@ public void execute()
180 180 final Archiver archiver = archiverManager.getArchiver( "zip" );
181 181
182 182 archiver.setDestFile( uberZip );
183   - archiver.setIncludeEmptyDirs( false );
184 183
185 184 if ( inputFile.isDirectory() )
186 185 {

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.