title: Unable to run repacked spring boot jar caused by "Unable to open nested entry"
body: <p>I am setting up a build pipeline for a spring boot project.</p>
  
  <p>It has three stages so far:</p>
  
  <pre><code>build: compile--&gt;unit test--&gt;archive the jar
  deploy acceptance test: repack the jar for acc environment (replacing datasource.properties etc)
  deploy uat test: repack the jar for uat environment (replacing datasource.properties etc)
  </code></pre>
  
  <p>I don't want to build the jar from scratch for different environments as it wastes time and potentially has risk of building inconsistent artifacts.
  For traditional war project, I just extract the war, replace the config files and repack. But this time with spring boot, somehow it does not work. When I run the repacked jar, it reports </p>
  
  <pre><code>java.lang.IllegalStateException: Unable to open nested entry 'lib/antlr-2.7.7.jar'. It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
      at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:378)
      at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:355)
      at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:341)
      at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:108)
      at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:92)
      at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:68)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:60)
      at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:45)
  </code></pre>
  
  <p>I extracted the origin jar and the repacked jar and don't find differences with lib folder.</p>
  
  <pre><code>task extractArtifact() {
      doLast {
  
          def outputDirName = "${buildDir}/tmp/under_config"
          def outputDir = file(outputDirName)
          assert outputDir.deleteDir()  // cleanup workspace
  
          def zipFile = file("${buildDir}/libs/${getArtifactName()}")
  
          copy {
              from zipTree(zipFile)
              into outputDir
          }
  
          copy {
              from file("${buildDir}/env")
              into file("${buildDir}/tmp/under_config")
          }
  
      }
  }
  
  task repackConfiguredArtifact(type: Zip, dependsOn: extractArtifact)  {
      archiveName = "${getArtifactName()}"
      destinationDir = file("${buildDir}/libs/${getEnv()}")
      from file("${buildDir}/tmp/under_config")
  }
  </code></pre>
  
  <p>Does anyone have an idea?</p>
  
  <p>Or how do you guys config the jar for different environment (without re-compile the binary).</p>