From 0df268c800648e58119b1db170819d9757c109fc Mon Sep 17 00:00:00 2001 From: Gary Clayburg <gclaybur@comcast.net> Date: Fri, 9 Jul 2021 16:20:53 -0600 Subject: [PATCH] #7 fix commonService file move error --- CHANGELOG.md | 37 ++++++++++ .../docker/DependencyMover.groovy | 12 ++- .../docker/BuildScriptsGradle5PlusSpec.groovy | 74 ------------------- 3 files changed, 46 insertions(+), 77 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f5c1c31 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,37 @@ +# Changelog + +## [1.4.1] - 2021-7-9 +Bug fixes for newer gradle and spring boot versions + +### Fixed +- using a commonService configuration on spring boot 2.4 would fail ([#7][i7]) +- expandBootJar fails with gradle 7.0.2 ([#8][i8]) + +### Notes +- This version is compatible with spring boot 1.5 and higher. This plugin has been tested with versions up to 2.5.2. +- This version is compatible with projects using gradle versions 4.10 and higher. It has been tested with versions up to 7.0.2 + +## [1.4.0] - 2020-3-14 +Older releases with release notes can be found on github [releases][releases] + +## [1.3.4] - 2020-3-11 +Older releases with release notes can be found on github [releases][releases] + +## [1.3.3] - 2020-3-10 +Older releases with release notes can be found on github [releases][releases] + +## [1.3.1] - 2018-3-9 +Older releases with release notes can be found on github [releases][releases] + +## [1.2.1] - 2018-2-18 +Older releases with release notes can be found on github [releases][releases] + +## [1.1.1] - 2018-1-26 +Older releases with release notes can be found on github [releases][releases] + +## [1.1.0] - 2017-10-17 +Older releases with release notes can be found on github [releases][releases] + +[i7]: https://github.com/gclayburg/dockerPreparePlugin/issues/7 +[i8]: https://github.com/gclayburg/dockerPreparePlugin/issues/8 +[releases]: https://github.com/gclayburg/dockerPreparePlugin/releases diff --git a/src/main/groovy/com/garyclayburg/docker/DependencyMover.groovy b/src/main/groovy/com/garyclayburg/docker/DependencyMover.groovy index a6e28fa..07d7165 100644 --- a/src/main/groovy/com/garyclayburg/docker/DependencyMover.groovy +++ b/src/main/groovy/com/garyclayburg/docker/DependencyMover.groovy @@ -48,9 +48,15 @@ class DependencyMover { some dependencies might only exist in providedRuntime configuration */ alreadyMovedJarfileNames.add(commonJarFile.name) - project.getLogger().info("common $configurationName dependency: "+commonJarFile.name) - project.ant.move(file: settings.dockerBuildDependenciesDirectory + partialPath + commonJarFile.name, - tofile: settings.commonServiceDependenciesDirectory + partialPath + commonJarFile.name) + project.getLogger().info("commonService $configurationName dependency: "+commonJarFile.name) + String srcFilename = settings.dockerBuildDependenciesDirectory + partialPath + commonJarFile.name + File srcFile = new File(srcFilename) + if (srcFile.exists()) { + project.ant.move(file: srcFilename, + tofile: settings.commonServiceDependenciesDirectory + partialPath + commonJarFile.name) + } else { + project.getLogger().info("cannot move file that doesn't exist: $srcFilename") + } } } diff --git a/src/test/groovy/com/garyclayburg/docker/BuildScriptsGradle5PlusSpec.groovy b/src/test/groovy/com/garyclayburg/docker/BuildScriptsGradle5PlusSpec.groovy index d159f82..7a515ed 100644 --- a/src/test/groovy/com/garyclayburg/docker/BuildScriptsGradle5PlusSpec.groovy +++ b/src/test/groovy/com/garyclayburg/docker/BuildScriptsGradle5PlusSpec.groovy @@ -80,80 +80,6 @@ test { useJUnitPlatform() } -//task buildImage(type: DockerBuildImage, dependsOn: 'dockerLayerPrepare') { -// description = 'Package application as Docker image' -// group = 'Docker' -// inputDir = project.file(dockerprepare.dockerBuildDirectory) -// images.add('registry:5000/' + rootProject.name +':latest') -//} -""" - when: - BuildResult result = GradleRunner.create() - .withProjectDir(testProjectDir.root) - .withArguments('build', '--stacktrace', '--info') - .withPluginClasspath() - .build() - println "build output is:" - println result.output - -// def count = new File(testProjectDir.root, -// 'build/docker/commonServiceDependenciesLayer1/BOOT-INF/lib') -// .listFiles().size() - - then: - result.output.contains('SUCCESSFUL') - result.task(':dockerLayerPrepare').outcome == SUCCESS - result.task(':expandBootJar').outcome == SUCCESS - -// count == 30 - } - - @SuppressWarnings('UnnecessaryQualifiedReference') - @IgnoreIf({ !SpecRoot.isUsingModernGradle() }) - def 'spring boot 2.4.2 with snapshots and docker buildimage'() { - given: - buildFile << """ -//import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage - -plugins { - id 'org.springframework.boot' version '2.4.2' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' -// id "com.gorylenko.gradle-git-properties" version '1.5.1' - id 'groovy' - id 'com.garyclayburg.dockerprepare' -// id 'com.bmuschko.docker-remote-api' version '6.4.0' -} - -group = 'com.garyclayburg' -version = '0.0.1-SNAPSHOT' -sourceCompatibility = '1.8' - -repositories { - mavenCentral() -// mavenLocal() -} - -dockerprepare { -// commonService = ['org.springframework.boot:spring-boot-starter-web'] - snapshotLayer = true -} - -dependencies { -// implementation group: 'com.garyclayburg', name:'upbanner-starter', version: '2.1.2-SNAPSHOT' - -// implementation 'com.github.oshi:oshi-core:5.3.6' - - implementation 'org.codehaus.groovy:groovy-all:3.0.4' - implementation 'org.springframework.boot:spring-boot-starter-actuator' - implementation 'org.springframework.boot:spring-boot-starter-web' -// developmentOnly 'org.springframework.boot:spring-boot-devtools' - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} - -test { - useJUnitPlatform() -} - //task buildImage(type: DockerBuildImage, dependsOn: 'dockerLayerPrepare') { // description = 'Package application as Docker image' // group = 'Docker'