Skip to content

Commit

Permalink
Merge pull request #5252 from bjhargrave/maven-it
Browse files Browse the repository at this point in the history
Maven integration test refactoring
  • Loading branch information
bjhargrave committed May 13, 2022
2 parents 951e81a + c559939 commit 81b1e84
Show file tree
Hide file tree
Showing 450 changed files with 3,079 additions and 1,584 deletions.
Expand Up @@ -5,6 +5,7 @@
import static org.eclipse.aether.metadata.Metadata.Nature.SNAPSHOT;

import java.io.File;
import java.util.Objects;

import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
Expand All @@ -15,6 +16,7 @@
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.metadata.DefaultMetadata;
import org.eclipse.aether.repository.ArtifactRepository;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
Expand Down Expand Up @@ -50,10 +52,8 @@ public ArtifactResult postProcessResult(ArtifactResult resolvedArtifact) throws
return resolvedArtifact;
}

String repoId = resolvedArtifact.getRepository()
.getId();
Artifact artifact = resolvedArtifact.getArtifact();
if ("workspace".equals(repoId) || "local".equals(repoId)) {
if (isLocalRepository(resolvedArtifact.getRepository())) {
Artifact artifact = resolvedArtifact.getArtifact();
logger.debug("Post processing {} to determine a remote source", artifact);
ArtifactResult postProcessed;
if (artifact.isSnapshot()) {
Expand All @@ -68,6 +68,21 @@ public ArtifactResult postProcessResult(ArtifactResult resolvedArtifact) throws
return resolvedArtifact;
}

private boolean isLocalRepository(ArtifactRepository repository) {
logger.debug("Checking for local repo {}", repository);
String repoId = repository.getId();
if (Objects.equals("workspace", repoId) || Objects.equals("local", repoId)) {
return true;
}
if (repository instanceof RemoteRepository) {
RemoteRepository remoteRepository = (RemoteRepository) repository;
if (Objects.equals("file", remoteRepository.getProtocol())) {
return true;
}
}
return false;
}

private ArtifactResult postProcessSnapshot(ArtifactRequest request, Artifact artifact)
throws MojoExecutionException {

Expand Down
15 changes: 0 additions & 15 deletions maven/bnd-baseline-maven-plugin/pom.xml
Expand Up @@ -53,19 +53,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<goals>
<goal>--no-transfer-progress</goal>
<goal>deploy</goal>
</goals>
</configuration>
</plugin>
</plugins>
</build>

</project>
@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress verify

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress verify

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,14 @@
import java.io.*;
import java.util.regex.Pattern

File build_log_file = new File("${basedir}/build.log")
assert build_log_file.exists();
def build_log = build_log_file.text

// With consumer
File invalid_with_consumer = new File("${basedir}/target/baseline/invalid-with-consumer-1.0.2.text")
assert invalid_with_consumer.isFile()
assert build_log =~ Pattern.quote("[WARNING] Baseline problems detected. See the report in ${invalid_with_consumer}")
assert build_log =~ Pattern.quote('* bnd.test PACKAGE MAJOR 1.0.0 1.0.0 2.0.0 1.1.0')


@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress verify

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,13 @@
import java.io.*;
import java.util.regex.Pattern

File build_log_file = new File("${basedir}/build.log")
assert build_log_file.exists();
def build_log = build_log_file.text

// With provider (require bundle version change)
File invalid_with_provider_require_bundle_version_change = new File("${basedir}/target/baseline/invalid-with-provider-require-bundle-version-change-1.0.1.txt")
assert invalid_with_provider_require_bundle_version_change.isFile()
assert build_log =~ Pattern.quote("[WARNING] Baseline problems detected. See the report in ${invalid_with_provider_require_bundle_version_change}")
assert build_log =~ Pattern.quote('* valid-no-previous BUNDLE MAJOR 1.0.1 1.0.1 1.1.0')

@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress verify

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,12 @@
import java.io.*;
import java.util.regex.Pattern

File build_log_file = new File("${basedir}/build.log")
assert build_log_file.exists();
def build_log = build_log_file.text

// With provider
File invalid_with_provider = new File("${basedir}/target/baseline/invalid-with-provider-1.0.2.txt")
assert invalid_with_provider.isFile()
assert build_log =~ Pattern.quote("[WARNING] Baseline problems detected. See the report in ${invalid_with_provider}")
assert build_log =~ Pattern.quote('* bnd.test PACKAGE MINOR 1.0.0 1.0.0 1.1.0 -')
10 changes: 10 additions & 0 deletions maven/bnd-baseline-maven-plugin/src/it/parent/invoker.properties
@@ -0,0 +1,10 @@
invoker.goals=--no-transfer-progress package

# Build parent before other tests
invoker.ordinal = 1000

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,30 +7,6 @@
<version>1.0.1</version>
<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<distributionManagement>
<repository>
<id>Test Repo</id>
<url>file:@project.build.directory@/integration-test/test-repo</url>
</repository>
</distributionManagement>

<modules>
<module>valid-no-previous</module>
<module>valid-with-previous-same</module>
<module>valid-with-provider</module>
<module>valid-with-provider-no-bundle-version-change</module>
<module>invalid-with-provider</module>
<module>invalid-with-provider-require-bundle-version-change</module>
<module>invalid-with-consumer</module>
<module>pre-diff</module>
<module>diffpackages</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -47,7 +23,7 @@
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-baseline-maven-plugin</artifactId>
<version>@project.version@</version>
<version>${bnd.version}</version>
<executions>
<execution>
<id>baseline</id>
Expand All @@ -60,7 +36,7 @@
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>@project.version@</version>
<version>${bnd.version}</version>
<executions>
<execution>
<id>default-bnd-process</id>
Expand All @@ -74,7 +50,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.10.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -88,13 +64,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.2</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
11 changes: 11 additions & 0 deletions maven/bnd-baseline-maven-plugin/src/it/pre-diff/invoker.properties
@@ -0,0 +1,11 @@
invoker.goals=--no-transfer-progress install

# This must be built before the other tests since they use this artifact as
# their baseline
invoker.ordinal = 100

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,11 @@
invoker.goals=--no-transfer-progress install

# This must be built before the other tests since they use this artifact as
# their baseline
invoker.ordinal = 100

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,9 @@
import java.io.*;
import java.util.regex.Pattern

File build_log_file = new File("${basedir}/build.log")
assert build_log_file.exists();
def build_log = build_log_file.text

// No previous
assert build_log =~ Pattern.quote('[WARNING] No previous version of biz.aQute.bnd-test:valid-no-previous:jar:1.0.1 could be found to baseline against')
@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress verify

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,11 @@
import java.io.*;
import java.util.regex.Pattern

File build_log_file = new File("${basedir}/build.log")
assert build_log_file.exists();
def build_log = build_log_file.text

// With previous-same
File valid_with_previous_same = new File("${basedir}/target/baseline/valid-with-previous-same-1.0.2.txt")
assert valid_with_previous_same.isFile()
assert build_log =~ Pattern.quote("[INFO] Baseline check succeeded. See the report in ${valid_with_previous_same}")
@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress verify

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,11 @@
import java.io.*;
import java.util.regex.Pattern

File build_log_file = new File("${basedir}/build.log")
assert build_log_file.exists();
def build_log = build_log_file.text

// With provider (no bundle version change required)
File valid_with_provider_no_bundle_version_change = new File("${basedir}/target/baseline/valid-with-provider-no-bundle-version-change-1.0.1.txt")
assert valid_with_provider_no_bundle_version_change.isFile()
assert build_log =~ Pattern.quote("[INFO] Baseline check succeeded. See the report in ${valid_with_provider_no_bundle_version_change}")
@@ -0,0 +1,7 @@
invoker.goals=--no-transfer-progress verify

# Run mvn with --debug for debug logging
#invoker.debug=true

# Run mvn in debugging mode and wait for a debugger to attach
#invoker.environmentVariables.MAVEN_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000
Expand Up @@ -7,6 +7,7 @@
<groupId>biz.aQute.bnd-test</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>biz.aQute.bnd-test</groupId>
Expand Down
@@ -0,0 +1,11 @@
import java.io.*;
import java.util.regex.Pattern

File build_log_file = new File("${basedir}/build.log")
assert build_log_file.exists();
def build_log = build_log_file.text

// With previous-provider
File valid_with_provider = new File("${basedir}/target/baseline/valid-with-provider-1.0.2.txt")
assert valid_with_provider.isFile()
assert build_log =~ Pattern.quote("[INFO] Baseline check succeeded. See the report in ${valid_with_provider}")

0 comments on commit 81b1e84

Please sign in to comment.