1

I am trying to achieve the same objective to the question posted here, namely to assemble a war dependency into a deployable zip, with both the war and some of its unpacked *.yml files in the final zip. I have the war file correctly assembled into the zip, but I can't get the maven-dependency-plugin to unpack the *.yml files out of the war for re-packing.

For clarity, this is what I have:

  • Project 1
    • Name: myapp-war
    • Packaging: war
  • Project 2
    • Name: myapp-deploy
    • Packaging: pom
    • Dependency: myapp-war:war
    • Desired output: myapp.zip which includes:
      • bin/myapp.war
      • conf/application-*.yml

Here's what my plugin declaration looks like:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>myapp</groupId>
                                <artifactId>myapp-war</artifactId>
                                <type>war</type>
                                <outputDirectory>${project.build.directory}/unpack</outputDirectory>
                                <includes>**/*.yml</includes>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

I've also tried a variant where I declared the <outputDirectory> and <includes> just underneath the <configuration>, which is permissible per the unpack mojo docs.

In either case, I get an empty myapp-deploy/target/unpack folder, along with [INFO] and [DEBUG] messages in the maven output stating:

[INFO] Configured Artifact: myapp:myapp-war:?:war
[INFO] Unpacking /build/myapp-war/target/myapp-war-0.0.1-SNAPSHOT.war to /build/myapp-deploy/target/unpack with includes "**/*.yml" and excludes ""
[DEBUG] Found unArchiver by type: org.codehaus.plexus.archiver.zip.ZipUnArchiver$__sisu2@692a65b1
[DEBUG] Expanding: /build/myapp-war/target/myapp-war-0.0.1-SNAPSHOT.war into /build/myapp-deploy/target/unpack
[DEBUG] expand complete

It appears that maven has understood my instructions, but doesn't seem to be unpacking as it claims to. Any idea what I'm doing wrong?

Community
  • 1
  • 1
chaserb
  • 1,340
  • 1
  • 14
  • 25

1 Answers1

1

There is apparently a problem with the creation of the *.war dependency. It is first created with maven-war-plugin:war, and then repackaged with the spring-boot-maven-plugin:repackage. Unzipping the war from the command line succeeds, but produces a warning:

$ unzip myapp-war-0.0.1-SNAPSHOT.war
Archive:  myapp-war-0.0.1-SNAPSHOT.war
warning [myapp-war-0.0.1-SNAPSHOT.war]:  7318 extra bytes at beginning or within zipfile

If I configure spring-boot-maven-plugin:repackage to disable the prepending of an executable *nix launch script to the war, maven-dependency-plugin:unpack works as expected:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>false</executable>
    </configuration>
</plugin>
chaserb
  • 1,340
  • 1
  • 14
  • 25