Allow integration tests to use custom repos

Update integration tests so that they can use a custom local Maven
repository.

See gh-9316
pull/10519/head
Phillip Webb 7 years ago
parent 4ff65d58a4
commit b6a83eb8f5

@ -54,6 +54,7 @@
<configuration> <configuration>
<systemPropertyVariables> <systemPropertyVariables>
<maven.home>${maven.home}</maven.home> <maven.home>${maven.home}</maven.home>
<repository>${repository}</repository>
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
</plugin> </plugin>

@ -25,6 +25,7 @@ import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.jar.JarOutputStream; import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
@ -37,6 +38,7 @@ import org.apache.maven.shared.invoker.MavenInvocationException;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -128,6 +130,12 @@ class ApplicationBuilder {
InvocationRequest invocation = new DefaultInvocationRequest(); InvocationRequest invocation = new DefaultInvocationRequest();
invocation.setBaseDirectory(appFolder); invocation.setBaseDirectory(appFolder);
invocation.setGoals(Collections.singletonList("package")); invocation.setGoals(Collections.singletonList("package"));
String repository = System.getProperty("repository");
if (StringUtils.hasText(repository) && !repository.equals("${repository}")) {
Properties properties = new Properties();
properties.put("repository", repository);
invocation.setProperties(properties);
}
InvocationResult execute = new DefaultInvoker().execute(invocation); InvocationResult execute = new DefaultInvoker().execute(invocation);
assertThat(execute.getExitCode()).isEqualTo(0); assertThat(execute.getExitCode()).isEqualTo(0);
} }

@ -61,4 +61,32 @@
</snapshots> </snapshots>
</repository> </repository>
</repositories> </repositories>
<profiles>
<profile>
<id>repository</id>
<activation>
<property>
<name>repository</name>
</property>
</activation>
<repositories>
<repository>
<id>repository</id>
<url>${repository}</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repository</id>
<url>${repository}</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project> </project>

Loading…
Cancel
Save