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 3.8.5 compatibility, update maven-invoker to 3.1.0 #24729

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci-actions-incremental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ jobs:
java-version: 11,
os-name: "ubuntu-latest"
}
- {
name: "11 mvn 3.8.5",
java-version: 11,
os-name: "ubuntu-latest",
mvn-version: 3.8.5
}
- {
name: "11 Windows",
java-version: 11,
Expand All @@ -382,6 +388,11 @@ jobs:
with:
distribution: temurin
java-version: ${{ matrix.java.java-version }}
- name: Switch Maven version
if: "matrix.java.mvn-version != ''"
run: |
echo 'distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/${{matrix.java.mvn-version}}/apache-maven-${{matrix.java.mvn-version}}-bin.zip' >> .mvn/wrapper/maven-wrapper.properties
./mvnw -version
- name: Build
# Important: keep -pl ... in sync with "Calculate run flags"!
run: ./mvnw $COMMON_MAVEN_ARGS $JVM_TEST_MAVEN_ARGS install -pl 'integration-tests/maven'
Expand Down
8 changes: 7 additions & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<kotlin.coroutine.version>1.6.0</kotlin.coroutine.version>
<kotlin-serialization.version>1.3.2</kotlin-serialization.version>
<dekorate.version>2.9.0</dekorate.version>
<maven-invoker.version>3.0.1</maven-invoker.version>
<maven-invoker.version>3.1.0</maven-invoker.version>
<awaitility.version>4.2.0</awaitility.version>
<jboss-logmanager.version>1.0.9</jboss-logmanager.version>
<flyway.version>8.5.5</flyway.version>
Expand Down Expand Up @@ -5040,6 +5040,12 @@
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
<version>${maven-invoker.version}</version>
<exclusions>
<exclusion>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.path.DefaultPathTranslator;
import org.apache.maven.model.path.PathTranslator;
import org.apache.maven.model.profile.DefaultProfileActivationContext;
import org.apache.maven.model.profile.DefaultProfileSelector;
import org.apache.maven.model.profile.activation.FileProfileActivator;
Expand Down Expand Up @@ -616,7 +617,7 @@ public List<org.apache.maven.model.Profile> getActiveSettingsProfiles()
.addProfileActivator(new PropertyProfileActivator())
.addProfileActivator(new JdkVersionProfileActivator())
.addProfileActivator(new OperatingSystemProfileActivator())
.addProfileActivator(new FileProfileActivator().setPathTranslator(new DefaultPathTranslator()));
.addProfileActivator(createFileProfileActivator());
modelProfiles = profileSelector.getActiveProfiles(modelProfiles, context, new ModelProblemCollector() {
public void add(ModelProblemCollectorRequest req) {
log.error("Failed to activate a Maven profile: " + req.getMessage());
Expand Down Expand Up @@ -961,4 +962,27 @@ private static boolean mirrorIsBlockedMethodAvailable() {
return false;
}
}

private static FileProfileActivator createFileProfileActivator() throws BootstrapMavenException {
var activator = new FileProfileActivator();
var translator = new DefaultPathTranslator();
try {
activator.setPathTranslator(translator);
} catch (LinkageError e) {
// setPathTranslator() not found; Maven >= 3.8.5 (https://github.com/apache/maven/pull/649)
try {
var interpolatorClass = Thread.currentThread().getContextClassLoader()
.loadClass("org.apache.maven.model.path.ProfileActivationFilePathInterpolator");
var interpolator = interpolatorClass.getDeclaredConstructor().newInstance();
interpolatorClass.getMethod("setPathTranslator", PathTranslator.class)
.invoke(interpolator, translator);
activator.getClass().getMethod("setProfileActivationFilePathInterpolator", interpolatorClass)
.invoke(activator, interpolator);
} catch (ReflectiveOperationException reflectionExc) {
throw new BootstrapMavenException("Failed to set up Maven 3.8.5+ ProfileActivationFilePathInterpolator",
reflectionExc);
}
}
return activator;
}
}
2 changes: 1 addition & 1 deletion independent-projects/bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<sisu.version>0.3.5</sisu.version><!-- Keep in sync with maven-core.version -->
<maven-plugin-annotations.version>3.6.0</maven-plugin-annotations.version>
<maven-resolver.version>1.6.3</maven-resolver.version>
<maven-shared-utils.version>3.3.4</maven-shared-utils.version> <!-- changed from the original version due to https://snyk.io/vuln/maven:org.apache.maven.shared:maven-shared-utils@3.2.1 -->
<maven-shared-utils.version>3.3.4</maven-shared-utils.version> <!-- Keep in sync with maven-core.version (force this version on maven-invoker) -->
<maven-wagon.version>3.4.3</maven-wagon.version>
<httpcore.version>4.4.15</httpcore.version><!-- Keep in sync with maven-wagon.version (wagon-http 3.4.3 brings in 4.4.13 and 4.4.14) -->
<commons-logging-jboss-logging.version>1.0.0.Final</commons-logging-jboss-logging.version>
Expand Down