From 3b9f40fd7512accd026103c53172e3621de85c12 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 7 Mar 2017 13:13:01 +0100 Subject: [PATCH] Works fine --- releaser-core/pom.xml | 10 ++++ .../cloud/release/ReleaserApplication.java | 48 ------------------- .../cloud/release/internal/PomUpdater.java | 16 +++++-- .../release/spring/ReleaserConfiguration.java | 20 -------- releaser-spring/pom.xml | 8 ---- .../cloud/release/ReleaserApplication.java | 5 +- 6 files changed, 25 insertions(+), 82 deletions(-) delete mode 100644 releaser-core/src/main/java/org/springframework/cloud/release/ReleaserApplication.java delete mode 100644 releaser-core/src/main/java/org/springframework/cloud/release/spring/ReleaserConfiguration.java diff --git a/releaser-core/pom.xml b/releaser-core/pom.xml index 7d9c0bd6..7040c0d4 100644 --- a/releaser-core/pom.xml +++ b/releaser-core/pom.xml @@ -42,6 +42,16 @@ org.codehaus.mojo versions-maven-plugin 2.3 + + + org.slf4j + slf4j-jdk14 + + + org.slf4j + jcl-over-slf4j + + org.springframework.boot diff --git a/releaser-core/src/main/java/org/springframework/cloud/release/ReleaserApplication.java b/releaser-core/src/main/java/org/springframework/cloud/release/ReleaserApplication.java deleted file mode 100644 index e343ef3e..00000000 --- a/releaser-core/src/main/java/org/springframework/cloud/release/ReleaserApplication.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2013-2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.cloud.release; - -import static org.slf4j.LoggerFactory.getLogger; - -import java.io.File; -import java.lang.invoke.MethodHandles; - -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.release.internal.ProjectUpdater; - -@SpringBootApplication -public class ReleaserApplication implements CommandLineRunner { - - private static final Logger log = getLogger(MethodHandles.lookup().lookupClass()); - - public static void main(String[] args) { - SpringApplication.run(ReleaserApplication.class, args); - } - - @Autowired ProjectUpdater projectUpdater; - - @Override public void run(String... strings) throws Exception { - String workingDir = System.getProperty("user.dir"); - log.info("Will run the application for root folder [{}]", workingDir); - log.info("Press any key to continue..."); - System.in.read(); - this.projectUpdater.updateProject(new File(workingDir)); - } -} diff --git a/releaser-core/src/main/java/org/springframework/cloud/release/internal/PomUpdater.java b/releaser-core/src/main/java/org/springframework/cloud/release/internal/PomUpdater.java index 893fc0ab..8d062e12 100644 --- a/releaser-core/src/main/java/org/springframework/cloud/release/internal/PomUpdater.java +++ b/releaser-core/src/main/java/org/springframework/cloud/release/internal/PomUpdater.java @@ -121,6 +121,10 @@ class PomUpdater { return changes; } } + if (oldVersion.equals(version)) { + log.info("Won't update the version of [{}]:[{}] since you're already using the proper one", parentGroupId, parentArtifactId); + return changes; + } log.info("Setting version of parent [{}] to [{}] for module [{}]", parentArtifactId, version, model.getArtifactId()); changes.add(new VersionChange(parentGroupId, parentArtifactId, oldVersion, version)); @@ -131,16 +135,20 @@ class PomUpdater { Model model, List sourceChanges) { String rootProjectName = wrapper.projectName(); List changes = new ArrayList<>(sourceChanges); - String parentGroupId = groupId(model); - String parentArtifactId = model.getArtifactId(); + String groupId = groupId(model); + String artifactId = model.getArtifactId(); String oldVersion = model.getVersion(); String version = versions.versionForProject(rootProjectName); if (StringUtils.isEmpty(version) || StringUtils.isEmpty(model.getVersion())) { log.warn("There was no version set for project [{}], skipping version setting for module [{}]", rootProjectName, model.getArtifactId()); return changes; } - log.info("Setting [{}] version to [{}]", model.getArtifactId(), version); - changes.add(new VersionChange(parentGroupId, parentArtifactId, oldVersion, version)); + if (oldVersion.equals(version)) { + log.info("Won't update the version of [{}]:[{}] since you're already using the proper one", groupId, artifactId); + return changes; + } + log.info("Setting [{}] version to [{}]", artifactId, version); + changes.add(new VersionChange(groupId, artifactId, oldVersion, version)); return changes; } diff --git a/releaser-core/src/main/java/org/springframework/cloud/release/spring/ReleaserConfiguration.java b/releaser-core/src/main/java/org/springframework/cloud/release/spring/ReleaserConfiguration.java deleted file mode 100644 index c68ab6f0..00000000 --- a/releaser-core/src/main/java/org/springframework/cloud/release/spring/ReleaserConfiguration.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.springframework.cloud.release.spring; - -/** - * @author Marcin Grzejszczak - */ - -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.release.internal.ProjectUpdater; -import org.springframework.cloud.release.internal.ReleaserProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableConfigurationProperties(ReleaserProperties.class) -class ReleaserConfiguration { - - @Bean ProjectUpdater projectUpdater(ReleaserProperties properties) { - return new ProjectUpdater(properties); - } -} diff --git a/releaser-spring/pom.xml b/releaser-spring/pom.xml index b69648bf..aed9de4f 100644 --- a/releaser-spring/pom.xml +++ b/releaser-spring/pom.xml @@ -23,14 +23,6 @@ - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-web - org.springframework.cloud releaser-core diff --git a/releaser-spring/src/main/java/org/springframework/cloud/release/ReleaserApplication.java b/releaser-spring/src/main/java/org/springframework/cloud/release/ReleaserApplication.java index e343ef3e..8f3fcbe4 100644 --- a/releaser-spring/src/main/java/org/springframework/cloud/release/ReleaserApplication.java +++ b/releaser-spring/src/main/java/org/springframework/cloud/release/ReleaserApplication.java @@ -15,8 +15,6 @@ */ package org.springframework.cloud.release; -import static org.slf4j.LoggerFactory.getLogger; - import java.io.File; import java.lang.invoke.MethodHandles; @@ -27,6 +25,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.release.internal.ProjectUpdater; +import static org.slf4j.LoggerFactory.getLogger; + @SpringBootApplication public class ReleaserApplication implements CommandLineRunner { @@ -44,5 +44,6 @@ public class ReleaserApplication implements CommandLineRunner { log.info("Press any key to continue..."); System.in.read(); this.projectUpdater.updateProject(new File(workingDir)); + System.exit(0); } }