From 140ecf4c8202eb1b0f8c1379e20700232321bf99 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Thu, 23 Jan 2020 12:52:30 +0100 Subject: [PATCH] Implement toolchain manager --- ...nitial-PoC-of-XMvn-toolchain-manager.patch | 77 +++++++++++++++++++ xmvn.spec | 8 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 0001-Initial-PoC-of-XMvn-toolchain-manager.patch diff --git a/0001-Initial-PoC-of-XMvn-toolchain-manager.patch b/0001-Initial-PoC-of-XMvn-toolchain-manager.patch new file mode 100644 index 0000000..37b1d81 --- /dev/null +++ b/0001-Initial-PoC-of-XMvn-toolchain-manager.patch @@ -0,0 +1,77 @@ +From c9362d3f23f950bb6987c63c67b06528de3ce100 Mon Sep 17 00:00:00 2001 +From: Mikolaj Izdebski +Date: Thu, 23 Jan 2020 12:50:42 +0100 +Subject: [PATCH] Initial PoC of XMvn toolchain manager + +--- + .../aether/XMvnMavenLifecycleParticipant.java | 38 +++++++++++++++++++ + 1 file changed, 38 insertions(+) + +diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMavenLifecycleParticipant.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMavenLifecycleParticipant.java +index 0e360488..ddd6151b 100644 +--- a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMavenLifecycleParticipant.java ++++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMavenLifecycleParticipant.java +@@ -15,10 +15,15 @@ + */ + package org.fedoraproject.xmvn.connector.aether; + ++import java.util.Collections; ++ + import org.apache.maven.AbstractMavenLifecycleParticipant; + import org.apache.maven.MavenExecutionException; + import org.apache.maven.execution.MavenExecutionRequest; + import org.apache.maven.execution.MavenSession; ++import org.apache.maven.project.MavenProject; ++import org.apache.maven.toolchain.MisconfiguredToolchainException; ++import org.apache.maven.toolchain.ToolchainManagerPrivate; + import org.codehaus.plexus.component.annotations.Component; + import org.codehaus.plexus.component.annotations.Requirement; + import org.codehaus.plexus.logging.Logger; +@@ -42,6 +47,9 @@ public class XMvnMavenLifecycleParticipant + @Requirement( role = XMvnMojoExecutionListener.class ) + private XMvnMojoExecutionListener mojoExecutionListener; + ++ @Requirement ++ private ToolchainManagerPrivate toolchainManager; ++ + @Override + public void afterSessionStart( MavenSession session ) + throws MavenExecutionException +@@ -61,4 +69,34 @@ public class XMvnMavenLifecycleParticipant + chainedListener.addExecutionListener( reportGenerator ); + request.setExecutionListener( chainedListener ); + } ++ ++ @Override ++ public void afterProjectsRead( MavenSession session ) ++ throws MavenExecutionException ++ { ++ MavenProject currentProject = session.getCurrentProject(); ++ ++ try ++ { ++ for ( var toolchain : toolchainManager.getToolchainsForType( "jdk", session ) ) ++ { ++ if ( toolchain.matchesRequirements( Collections.singletonMap( "xmvn", "xmvn" ) ) ) ++ { ++ for ( var project : session.getAllProjects() ) ++ { ++ session.setCurrentProject( project ); ++ toolchainManager.storeToolchainToBuildContext( toolchain, session ); ++ } ++ } ++ } ++ } ++ catch ( MisconfiguredToolchainException e ) ++ { ++ throw new MavenExecutionException( "Unable to configure toolchains", e ); ++ } ++ finally ++ { ++ session.setCurrentProject( currentProject ); ++ } ++ } + } +-- +2.21.0 + diff --git a/xmvn.spec b/xmvn.spec index b23d524..d98e4ee 100644 --- a/xmvn.spec +++ b/xmvn.spec @@ -5,7 +5,7 @@ Name: xmvn Version: 4.0.0~20191028.da67577 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Local Extensions for Apache Maven License: ASL 2.0 URL: https://fedora-java.github.io/xmvn/ @@ -14,6 +14,8 @@ BuildArch: noarch #Source0: https://github.com/fedora-java/xmvn/releases/download/%{version}/xmvn-%{version}.tar.xz Source0: https://github.com/fedora-java/xmvn/archive/da67577.tar.gz +Patch0: 0001-Initial-PoC-of-XMvn-toolchain-manager.patch + BuildRequires: maven-local BuildRequires: mvn(com.beust:jcommander) BuildRequires: mvn(org.apache.commons:commons-compress) @@ -190,6 +192,7 @@ This package provides %{summary}. %prep %setup -q -n xmvn-da67577d9252f0b1fffed546c7c23d97a97dec4b +%patch0 -p1 # Bisect IT has no chances of working in local, offline mode, without # network access - it needs to access remote repositories. @@ -334,6 +337,9 @@ cp -P ${maven_home}/bin/m2.conf %{buildroot}%{_datadir}/%{name}/bin/ %doc LICENSE NOTICE %changelog +* Thu Jan 23 2020 Mikolaj Izdebski - 4.0.0~20191028.da67577-3 +- Implement toolchain manager + * Tue Nov 05 2019 Mikolaj Izdebski - 4.0.0~20191028.da67577-2 - Mass rebuild for javapackages-tools 201902