Skip to content

Commit

Permalink
Merge pull request #396 from chali/BootJarAndJarNameConflict
Browse files Browse the repository at this point in the history
bootJar and jar task output name is the same which can cause overriding and bundling wrong jar in debian
  • Loading branch information
chali authored Feb 23, 2021
2 parents d635065 + 6093af6 commit 6905886
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ class OspackageApplicationSpringBootPlugin implements Plugin<Project> {
enabled = true
}
project.afterEvaluate {
project.bootJar {
if(GradleVersion.current().baseVersion < GradleVersion.version('6.0').baseVersion) {
classifier = "boot"
} else {
archiveClassifier = "boot"
}
}
project.distributions {
main {
if(GradleVersion.current().baseVersion < GradleVersion.version('6.0').baseVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import org.junit.Rule
import org.junit.contrib.java.lang.system.ProvideSystemProperty
import spock.lang.Unroll

import java.util.jar.JarEntry
import java.util.jar.JarFile

class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {

@Rule
Expand Down Expand Up @@ -67,6 +70,8 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter:$bootVersion'
}
bootJar.mustRunAfter jar
ospackage {
packageName = 'test'
Expand All @@ -87,7 +92,7 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
buildFile << buildScript(bootVersion, null)

when:
runTasksSuccessfully('buildDeb')
runTasksSuccessfully('build', 'buildDeb')

then:
final archivePath = file("build/distributions/test_0_all.deb")
Expand All @@ -103,13 +108,23 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec {
assert scanner.getEntry("${it}").isFile()
}

//make sure we don't have boot jar in debian
def jarFile = new JarFile(scanner.getEntryFile(moduleJarName))
! isBootJar(jarFile)

!scanner.controlContents.containsKey('./postinst')

where:
bootVersion | fileMode
'2.4.2' | 0755
}

private boolean isBootJar(JarFile jarFile) {
jarFile.entries().any {
it.name.contains("BOOT-INF")
}
}

@Unroll
def 'application runs for boot #bootVersion'() {
final applicationDir = "$moduleName-boot"
Expand Down

0 comments on commit 6905886

Please # to comment.