Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven integration test refactoring #5252

Merged
merged 16 commits into from May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
a233d08
maven: Move plugin integration tests to src/it
bjhargrave May 10, 2022
3c5e93f
maven: Use conventional names for pre and post build it scripts
bjhargrave May 10, 2022
a403ec0
maven: maven-invoker-plugin configuration improvements
bjhargrave May 10, 2022
1398589
maven: Use test classpath for pre and post build it scripts
bjhargrave May 10, 2022
870def4
maven: Configure it execution goals through invoker.properties
bjhargrave May 10, 2022
fc59e3c
maven: use properties passed from maven-invoker-plugin config
bjhargrave May 10, 2022
1e2d69b
maven: Add help mojo to maven plugins
bjhargrave May 10, 2022
9863ed5
maven: Refactor baseline integration tests into separate test projects
bjhargrave May 10, 2022
b9af1a1
maven: Refactor export integration tests into separate test projects
bjhargrave May 11, 2022
cb1b734
maven: Treat a remote repository with file protocol as a local repo
bjhargrave May 11, 2022
49011f7
maven: Refactor indexer integration tests into separate test projects
bjhargrave May 12, 2022
86ddf01
maven: Refactor reporter integration tests into separate test projects
bjhargrave May 12, 2022
6678504
maven: Refactor resolver integration tests into separate test projects
bjhargrave May 12, 2022
2539a5d
maven: Fix run integration tests invoker settings
bjhargrave May 12, 2022
9b7f8c6
maven: Refactor testing integration tests into separate test projects
bjhargrave May 12, 2022
c559939
maven: Refactor maven integration tests into separate test projects
bjhargrave May 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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}")