Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explode WAR instead of working on exploded WAR directory for Maven #1091

Closed
chanseokoh opened this issue Oct 3, 2018 · 7 comments · Fixed by #2069
Closed

Explode WAR instead of working on exploded WAR directory for Maven #1091

chanseokoh opened this issue Oct 3, 2018 · 7 comments · Fixed by #2069

Comments

@chanseokoh
Copy link
Member

Explode the WAR file rather than using this directory. The contents of the final WAR may be different from this directory (it's possible to include or exclude files when packaging a WAR. Also the exploded WAR directory is configurable with <webappDirectory> and may not be at build.getFinalName().

https://github.com/GoogleContainerTools/jib/pull/1068/files#r221696396

@chanseokoh
Copy link
Member Author

FYI @edrandall

@chanseokoh chanseokoh removed the question User inquiries label Oct 14, 2019
@edrandall
Copy link

edrandall commented Oct 15, 2019

(Redirected from Jib seems to strip .war file META-INF/ contents from image #2064)
Basically this Jib behaviour is a total blocker for us.

It's been a long-standing convention in all of our web applications (we have a large number) that we store versioning information about the build within the MANIFEST.MF. We have an API which makes this available to monitoring and healthcheck systems. We absolutely need this information present in the build as we migrate to cloud.

META-INF/MANIFEST.MF is part of the .jar file spec which, whilst "optional", is pretty much guaranteed to be present, it's designed for storing exactly this type information. Digital signatues are also stored in the META-INF/ directory. Ref. https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html and anyone using them will require this.

Further, this is required by anyone using the extension mechanism. The Servlet Spec 2.4 SRV.9.7.1 (my emphasis on the must):

"The application developer depending on such an extension or extensions must provide a META-INF/MANIFEST.MF entry in the WAR file listing all extensions needed by the WAR. "

Just curious, where is it documented that Jib actually changes the deployed files in this way, a brief search found nothing (not even this ticket)?

@chanseokoh
Copy link
Member Author

chanseokoh commented Oct 15, 2019

Thanks for the detailed explanation. That makes sense.

Jib doesn't change the deployed files. It is just that by default, Jib is supposed to put exploded WAR contents, but because of this issue that it is using the intermediate exploded WAR directory prepared by Maven (whose contents are often same as the final WAR) instead of actually exploding the final WAR, incomplete META-INF/MANIFEST.MF will be put into the image. I think once we fix this, your issue will be resolved.

BTW, Jib Gradle does explode the final WAR, so this issue is present only for Maven.

@edrandall
Copy link

edrandall commented Oct 15, 2019

Thanks - so it's something of a side-effect of Jib doing this and the order in which Maven builds things, have I got that right?
Any idea how soon this can be fixed? We're trying to migrate a lot of projects and Jib is a good strategic solution, but we may need to implement a tactical workaround depending on timeline.

@chanseokoh
Copy link
Member Author

Yeah, Maven prepares exploded WAR contents in a build output directory before finally zipping them up into a WAR file, and we've been lazy to use that intermediate directory instead of unzipping the WAR ourselves. This works in many cases, as the contents are often same except for files like MANIFEST.MF, but yeah, it is time to fix this.

This should be easy to fix, so I will see if we can fix this before our next release.

In the meantime, if you have a Gradle project, you may try Jib Gradle just to see if it works as desired.

@edrandall
Copy link

edrandall commented Oct 16, 2019

The following maven 'hack' seems to provide a crude workaround, by extracting the META-INF/ from the war into the working dir after packaging but before the Jib goal executes:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>3.1.1</version
  <executions>
    <execution>
      <id>unpack-meta-inf</id>
      <phase>package</phase>
      <goals>
        <goal>unpack</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>${project.groupId}</groupId>
            <artifactId>${project.artifactId}</artifactId>
            <version>${project.version}</version>
            <type>war</type>
            <overWrite>true</overWrite>
            <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
            <includes>META-INF/</includes>
          </artifactItem>
        </artifactItems>
      </configuration>
    </execution>
  </executions>
</plugin>

@TadCordle
Copy link
Contributor

@edrandall @joelhandwell @Daiki-Kawanuma @cessien @kurczynski @CauchyPeano We've released v1.7.0 with this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants