commit e01aa4f1a22bf32543bc593efbb5f55531c833e5 Author: Marcin Grzejszczak Date: Mon Mar 6 12:33:50 2017 +0100 Added project cloner diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2af7cefb --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ \ No newline at end of file diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 00000000..5fd4d502 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..c954cec9 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip diff --git a/mvnw b/mvnw new file mode 100755 index 00000000..a1ba1bf5 --- /dev/null +++ b/mvnw @@ -0,0 +1,233 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + wdir=$(cd "$wdir/.."; pwd) + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 00000000..2b934e89 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..f4512614 --- /dev/null +++ b/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + + org.springframework.cloud + releaser + 0.0.1-SNAPSHOT + jar + + releaser + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.0.BUILD-SNAPSHOT + + + + + UTF-8 + UTF-8 + 1.8 + + + + + + org.eclipse.jgit + org.eclipse.jgit + 4.6.0.201612231935-r + + + + + + + org.springframework.boot + spring-boot-starter + + + org.eclipse.jgit + org.eclipse.jgit + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + diff --git a/src/main/java/org/springframework/cloud/release/ProjectCloner.java b/src/main/java/org/springframework/cloud/release/ProjectCloner.java new file mode 100644 index 00000000..98582a2e --- /dev/null +++ b/src/main/java/org/springframework/cloud/release/ProjectCloner.java @@ -0,0 +1,90 @@ +package org.springframework.cloud.release; + +import java.io.File; +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.net.URI; + +import org.eclipse.jgit.api.CloneCommand; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.util.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Marcin Grzejszczak + */ +class ProjectCloner { + + private static final Logger log = LoggerFactory + .getLogger(MethodHandles.lookup().lookupClass()); + + private final ProjectCloner.JGitFactory gitFactory; + + private final File basedir; + + ProjectCloner(File basedir) { + this.basedir = basedir; + this.gitFactory = new ProjectCloner.JGitFactory(); + } + + ProjectCloner(File basedir, ProjectCloner.JGitFactory factory) { + this.basedir = basedir; + this.gitFactory = factory; + } + + File cloneProject(URI projectUrl) { + try { + if (log.isDebugEnabled()) { + log.debug("Cloning repo from [{}] to [{}]", projectUrl, this.basedir); + } + Git git = cloneToBasedir(projectUrl, this.basedir); + if (git != null) { + git.close(); + } + File clonedRepo = git.getRepository().getDirectory(); + if (log.isDebugEnabled()) { + log.debug("Cloned repo to [{}]", clonedRepo); + } + return clonedRepo; + } + catch (Exception e) { + throw new IllegalStateException(e); + } + } + + private Git cloneToBasedir(URI projectUrl, File destinationFolder) + throws GitAPIException { + CloneCommand clone = this.gitFactory.getCloneCommandByCloneRepository() + .setURI(projectUrl.toString() + ".git").setDirectory(destinationFolder); + try { + return clone.call(); + } + catch (GitAPIException e) { + deleteBaseDirIfExists(); + throw e; + } + } + + private void deleteBaseDirIfExists() { + if (this.basedir.exists()) { + try { + FileUtils.delete(this.basedir, FileUtils.RECURSIVE); + } + catch (IOException e) { + throw new IllegalStateException("Failed to initialize base directory", e); + } + } + } + + /** + * Wraps the static method calls to {@link org.eclipse.jgit.api.Git} and + * {@link org.eclipse.jgit.api.CloneCommand} allowing for easier unit testing. + */ + static class JGitFactory { + CloneCommand getCloneCommandByCloneRepository() { + return Git.cloneRepository(); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/springframework/cloud/release/ReleaserApplication.java b/src/main/java/org/springframework/cloud/release/ReleaserApplication.java new file mode 100644 index 00000000..0694bb57 --- /dev/null +++ b/src/main/java/org/springframework/cloud/release/ReleaserApplication.java @@ -0,0 +1,12 @@ +package org.springframework.cloud.release; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ReleaserApplication { + + public static void main(String[] args) { + SpringApplication.run(ReleaserApplication.class, args); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 00000000..e69de29b diff --git a/src/test/java/org/springframework/cloud/release/AcceptanceTests.java b/src/test/java/org/springframework/cloud/release/AcceptanceTests.java new file mode 100644 index 00000000..0a6d8413 --- /dev/null +++ b/src/test/java/org/springframework/cloud/release/AcceptanceTests.java @@ -0,0 +1,23 @@ +package org.springframework.cloud.release; + +import org.junit.Test; + +/** + * @author Marcin Grzejszczak + */ +public class AcceptanceTests { + + /** + + - should clone spring cloud release + - should check out a branch / tag + - should parse spring-cloud-dependencies/pom.xml and resolve: + - Boot version + - Project versions from properties + - Spring Cloud Build version from parent + - should update the existing poms with the taken versions + */ + @Test + public void should_update_all_versions_for_a_release_train() { + } +} diff --git a/src/test/java/org/springframework/cloud/release/ProjectClonerTests.java b/src/test/java/org/springframework/cloud/release/ProjectClonerTests.java new file mode 100644 index 00000000..7c64aa23 --- /dev/null +++ b/src/test/java/org/springframework/cloud/release/ProjectClonerTests.java @@ -0,0 +1,57 @@ +package org.springframework.cloud.release; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; + +import org.eclipse.jgit.api.CloneCommand; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import static org.assertj.core.api.BDDAssertions.then; + +/** + * @author Marcin Grzejszczak + */ +public class ProjectClonerTests { + + @Rule public TemporaryFolder tmp = new TemporaryFolder(); + File springCloudReleaseProject; + File tmpFolder; + ProjectCloner projectCloner; + + @Before + public void setup() throws IOException, URISyntaxException { + this.tmpFolder = this.tmp.newFolder(); + this.springCloudReleaseProject = new File(ProjectClonerTests.class.getResource("/projects/spring-cloud-release").toURI()); + TestUtils.prepareLocalRepo(); + this.projectCloner = new ProjectCloner(this.tmpFolder); + } + + @Test + public void should_clone_the_project_from_a_given_location() throws IOException { + this.projectCloner.cloneProject(this.springCloudReleaseProject.toURI()); + + then(new File(this.tmpFolder, ".git")).exists(); + } + + @Test(expected = IllegalStateException.class) + public void should_throw_exception_when_there_is_no_repo() + throws IOException, URISyntaxException { + this.projectCloner.cloneProject(ProjectClonerTests.class.getResource("/projects/").toURI()); + } + + @Test(expected = IllegalStateException.class) + public void should_throw_an_exception_when_failed_to_initialize_the_repo() throws IOException { + new ProjectCloner(this.tmpFolder, new ExceptionThrowingJGitFactory()).cloneProject(this.springCloudReleaseProject.toURI()); + } + +} + +class ExceptionThrowingJGitFactory extends ProjectCloner.JGitFactory { + @Override CloneCommand getCloneCommandByCloneRepository() { + throw new RuntimeException("foo"); + } +} \ No newline at end of file diff --git a/src/test/java/org/springframework/cloud/release/TestUtils.java b/src/test/java/org/springframework/cloud/release/TestUtils.java new file mode 100644 index 00000000..c0486b7b --- /dev/null +++ b/src/test/java/org/springframework/cloud/release/TestUtils.java @@ -0,0 +1,25 @@ +package org.springframework.cloud.release; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.jgit.util.FileUtils; + +public class TestUtils { + + public static void prepareLocalRepo() throws IOException { + prepareLocalRepo("target/test-classes/projects/", "spring-cloud-release"); + } + + private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException { + File dotGit = new File(buildDir + repoPath + "/.git"); + File git = new File(buildDir + repoPath + "/git"); + if (git.exists()) { + if (dotGit.exists()) { + FileUtils.delete(dotGit, FileUtils.RECURSIVE); + } + } + git.renameTo(dotGit); + } + +} \ No newline at end of file diff --git a/src/test/resources/projects/sample/pom.xml b/src/test/resources/projects/sample/pom.xml new file mode 100644 index 00000000..74e886d8 --- /dev/null +++ b/src/test/resources/projects/sample/pom.xml @@ -0,0 +1,376 @@ + + + 4.0.0 + + spring-cloud-sleuth + 1.2.0.BUILD-SNAPSHOT + pom + Spring Cloud Sleuth + Spring Cloud Sleuth + + + org.springframework.cloud + spring-cloud-build + 1.3.1.BUILD-SNAPSHOT + + + + + + https://github.com/spring-cloud/spring-cloud-sleuth + scm:git:git://github.com/spring-cloud/spring-cloud-sleuth.git + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-sleuth.git + HEAD + + + + spring-cloud-sleuth-dependencies + spring-cloud-sleuth-core + spring-cloud-sleuth-zipkin + spring-cloud-sleuth-stream + spring-cloud-sleuth-zipkin-stream + spring-cloud-starter-sleuth + spring-cloud-starter-zipkin + spring-cloud-sleuth-samples + docs + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + + default-compile + + true + true + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + default-testCompile + + true + true + + ${maven.compiler.testSource} + ${maven.compiler.testTarget} + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.3.1 + + + enforce-java + + enforce + + + + + ${maven.compiler.testTarget} + + + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${checkstyle.version} + + + org.springframework.cloud + spring-cloud-build-tools + ${spring-cloud-build.version} + + + + + validate + validate + + checkstyle.xml + LICENSE.txt + true + true + + + check + + + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${checkstyle.version} + + checkstyle.xml + LICENSE.txt + + + + + + + + + org.springframework.cloud + spring-cloud-sleuth-dependencies + ${project.version} + pom + import + + + org.springframework.cloud + spring-cloud-netflix-dependencies + ${spring-cloud-netflix.version} + pom + import + + + org.springframework.cloud + spring-cloud-commons-dependencies + ${spring-cloud-commons.version} + pom + import + + + org.springframework.cloud + spring-cloud-stream-dependencies + ${spring-cloud-stream.version} + pom + import + + + + org.spockframework + spock-core + ${spock.version} + test + + + org.spockframework + spock-spring + ${spock.version} + test + + + cglib + cglib-nodep + 3.1 + + + org.objenesis + objenesis + 2.1 + + + + org.hamcrest + hamcrest-core + test + + + com.jayway.awaitility + awaitility + 1.7.0 + test + + + com.github.tomakehurst + wiremock + 2.5.1 + test + + + pl.pragmatists + JUnitParams + 1.0.6 + test + + + org.assertj + assertj-core + 3.6.2 + test + + + + + + 1.7 + 1.7 + 1.8 + 1.8 + 2.19.1 + 2.17 + 1.3.1.BUILD-SNAPSHOT + 1.2.0.BUILD-SNAPSHOT + Chelsea.BUILD-SNAPSHOT + 1.3.0.BUILD-SNAPSHOT + + + + + spring + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + false + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + false + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/libs-release-local + + false + + + + + + ide + + false + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${maven.compiler.testSource} + ${maven.compiler.testTarget} + + + + + + + benchmarks + + false + + + benchmarks + + + + sonar + + + + org.jacoco + jacoco-maven-plugin + + + pre-unit-test + + prepare-agent + + + surefireArgLine + ${project.build.directory}/jacoco.exec + + + + post-unit-test + test + + report + + + + ${project.build.directory}/jacoco.exec + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + + ${surefireArgLine} + + + + + + + + diff --git a/src/test/resources/projects/sample/spring-cloud-sleuth-core/pom.xml b/src/test/resources/projects/sample/spring-cloud-sleuth-core/pom.xml new file mode 100644 index 00000000..80e1909c --- /dev/null +++ b/src/test/resources/projects/sample/spring-cloud-sleuth-core/pom.xml @@ -0,0 +1,165 @@ + + + 4.0.0 + + spring-cloud-sleuth-core + jar + Spring Cloud Sleuth Core + Spring Cloud Sleuth Core + + + org.springframework.cloud + spring-cloud-sleuth + 1.2.0.BUILD-SNAPSHOT + .. + + + + + org.springframework.boot + spring-boot-starter-web + true + + + org.springframework.boot + spring-boot-starter-websocket + true + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.springframework.boot + spring-boot-starter-actuator + true + + + org.springframework.cloud + spring-cloud-commons + + + org.springframework.cloud + spring-cloud-starter-feign + true + + + org.springframework.cloud + spring-cloud-starter-zuul + true + + + org.springframework.integration + spring-integration-core + true + + + org.springframework + spring-context + + + com.netflix.hystrix + hystrix-core + true + + + io.github.openfeign + feign-core + true + + + com.netflix.zuul + zuul-core + true + + + io.reactivex + rxjava + true + + + + org.springframework.data + spring-data-rest-webmvc + true + + + com.squareup.okhttp3 + okhttp + true + + + org.apache.httpcomponents + httpclient + true + + + io.github.openfeign + feign-okhttp + true + + + org.aspectj + aspectjrt + + + org.springframework.boot + spring-boot-starter-test + test + + + com.netflix.archaius + archaius-core + test + + + com.squareup.okhttp3 + mockwebserver + 3.1.2 + test + + + org.assertj + assertj-core + test + + + com.jayway.awaitility + awaitility + test + + + pl.pragmatists + JUnitParams + test + + + org.springframework.boot + spring-boot-starter-data-jpa + test + + + org.springframework + spring-orm + test + + + org.springframework.boot + spring-boot-starter-data-rest + test + + + com.h2database + h2 + test + + + org.springframework.cloud + spring-cloud-starter-eureka + test + + + + diff --git a/src/test/resources/projects/sample/spring-cloud-sleuth-dependencies/pom.xml b/src/test/resources/projects/sample/spring-cloud-sleuth-dependencies/pom.xml new file mode 100644 index 00000000..b58f2f13 --- /dev/null +++ b/src/test/resources/projects/sample/spring-cloud-sleuth-dependencies/pom.xml @@ -0,0 +1,139 @@ + + + 4.0.0 + + spring-cloud-dependencies-parent + org.springframework.cloud + 1.3.1.BUILD-SNAPSHOT + + + spring-cloud-sleuth-dependencies + 1.2.0.BUILD-SNAPSHOT + pom + spring-cloud-sleuth-dependencies + Spring Cloud Sleuth Dependencies + + 1.19.2 + 0.6.12 + + + + + org.springframework.cloud + spring-cloud-sleuth-core + ${project.version} + + + org.springframework.cloud + spring-cloud-sleuth-zipkin + ${project.version} + + + org.springframework.cloud + spring-cloud-sleuth-stream + ${project.version} + + + org.springframework.cloud + spring-cloud-sleuth-zipkin-stream + ${project.version} + + + org.springframework.cloud + spring-cloud-starter-zipkin + ${project.version} + + + org.springframework.cloud + spring-cloud-starter-sleuth + ${project.version} + + + io.zipkin.java + zipkin + ${zipkin.version} + + + io.zipkin.java + zipkin-server + ${zipkin.version} + + + io.zipkin.java + zipkin-autoconfigure-ui + ${zipkin.version} + + + io.zipkin.java + zipkin-autoconfigure-storage-mysql + ${zipkin.version} + + + io.zipkin.java + zipkin-junit + ${zipkin.version} + + + io.zipkin.reporter + zipkin-reporter + ${zipkin-reporter.version} + + + + + + spring + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + false + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + false + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + + + + diff --git a/src/test/resources/projects/spring-cloud-release b/src/test/resources/projects/spring-cloud-release new file mode 160000 index 00000000..320597b8 --- /dev/null +++ b/src/test/resources/projects/spring-cloud-release @@ -0,0 +1 @@ +Subproject commit 320597b84bb0312c15228c4d42f46c189b86ed90