From 53ac9ec27529ec5e6f1353b3c622407cf38200b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 24 Jan 2022 12:44:17 +0100 Subject: [PATCH] Add generic tycho-build core extension - Issue #556 add a tycho-core-extension including pomless - Issue #148 add a hint to the user to migrate to the generic extension - Update integration tests to use the new tycho-core-extension --- RELEASE_NOTES.md | 27 +++++++ pom.xml | 2 + tycho-build/pom.xml | 50 +++++++++++++ tycho-extras/pom.xml | 6 -- .../testpomless-flat/.mvn/extensions.xml | 4 +- .../.mvn/extensions.xml | 4 +- .../resources/testpomless/.mvn/extensions.xml | 4 +- .../testsetversionpomless/.mvn/extensions.xml | 4 +- tycho-extras/tycho-pomless/pom.xml | 6 ++ .../TychoPomlessLifecycleParticipant.java | 70 +++++++++++++++++++ 10 files changed, 163 insertions(+), 14 deletions(-) create mode 100644 tycho-build/pom.xml create mode 100644 tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoPomlessLifecycleParticipant.java diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ef54c4a08e..8c4a6f8b47 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,6 +4,33 @@ This page describes the noteworthy improvements provided by each release of Ecli ## 2.7.0 (under development) +### Tycho-Pomless will become a tycho-core extension + +Tycho pomless has started as a small experiment in tycho-extras. Over time it has grown to a fully-fledged solution to build pde-based artifacts with less effort and nearly zero additional configuration. + +Neverless, the name "pomless" was always a bit misleading, as actually we have reduced the number required poms to one 'main-pom' it is still not pomless and actually allows poms to be used where suitable. +Because of this, an to not limit the usage to "pomless" with this version a new core-extension is available name 'tycho-build', that effectively does what tycho-extras-pomless does but in the context of 'core' and is open to further improvements +(maybe some time offering an option to not needing a pom at all). + +All that needs to be done is replace the old +``` + + org.eclipse.tycho.extras + tycho-pomless + 2.7.0 + +``` + +with + +``` + + org.eclipse.tycho + tycho-build + 2.7.0 + +``` + ### Mixed reactor build support previously Tycho has resolved pom considered depdencies as part of the inital maven setup (before the actual build starts). This has lead to the fact that it was not possible to mix projects that e.g. dynamically generate a manifest. diff --git a/pom.xml b/pom.xml index 3572c0c6c9..fdcfbaf2d6 100644 --- a/pom.xml +++ b/pom.xml @@ -493,6 +493,7 @@ tycho-gpg-plugin tycho-extras + tycho-build @@ -500,6 +501,7 @@ its tycho-its + tycho-extras/tycho-extras-its diff --git a/tycho-build/pom.xml b/tycho-build/pom.xml new file mode 100644 index 0000000000..21c2970660 --- /dev/null +++ b/tycho-build/pom.xml @@ -0,0 +1,50 @@ + + 4.0.0 + + org.eclipse.tycho + tycho + 2.7.0-SNAPSHOT + + tycho-build + + + + + + org.codehaus.plexus + plexus-component-metadata + + + + + + + + org.codehaus.plexus + plexus-utils + provided + + + + org.eclipse.tycho.extras + tycho-pomless + ${project.version} + + + org.apache.maven + maven-model + provided + + + org.apache.maven + maven-model-builder + ${maven-version} + provided + + + org.apache.maven + maven-core + provided + + + \ No newline at end of file diff --git a/tycho-extras/pom.xml b/tycho-extras/pom.xml index aa925c627c..d4e21189fd 100644 --- a/tycho-extras/pom.xml +++ b/tycho-extras/pom.xml @@ -192,12 +192,6 @@ - - its - - tycho-extras-its - - pack200 diff --git a/tycho-extras/tycho-extras-its/src/test/resources/testpomless-flat/.mvn/extensions.xml b/tycho-extras/tycho-extras-its/src/test/resources/testpomless-flat/.mvn/extensions.xml index b890ce96e4..3a98405242 100644 --- a/tycho-extras/tycho-extras-its/src/test/resources/testpomless-flat/.mvn/extensions.xml +++ b/tycho-extras/tycho-extras-its/src/test/resources/testpomless-flat/.mvn/extensions.xml @@ -1,8 +1,8 @@ - org.eclipse.tycho.extras - tycho-pomless + org.eclipse.tycho + tycho-build ${tycho-version} diff --git a/tycho-extras/tycho-extras-its/src/test/resources/testpomless-structured/.mvn/extensions.xml b/tycho-extras/tycho-extras-its/src/test/resources/testpomless-structured/.mvn/extensions.xml index b890ce96e4..3a98405242 100644 --- a/tycho-extras/tycho-extras-its/src/test/resources/testpomless-structured/.mvn/extensions.xml +++ b/tycho-extras/tycho-extras-its/src/test/resources/testpomless-structured/.mvn/extensions.xml @@ -1,8 +1,8 @@ - org.eclipse.tycho.extras - tycho-pomless + org.eclipse.tycho + tycho-build ${tycho-version} diff --git a/tycho-extras/tycho-extras-its/src/test/resources/testpomless/.mvn/extensions.xml b/tycho-extras/tycho-extras-its/src/test/resources/testpomless/.mvn/extensions.xml index b890ce96e4..8d6d7f3368 100644 --- a/tycho-extras/tycho-extras-its/src/test/resources/testpomless/.mvn/extensions.xml +++ b/tycho-extras/tycho-extras-its/src/test/resources/testpomless/.mvn/extensions.xml @@ -1,8 +1,8 @@ - org.eclipse.tycho.extras - tycho-pomless + org.eclipse.tycho + tycho-build ${tycho-version} diff --git a/tycho-extras/tycho-extras-its/src/test/resources/testsetversionpomless/.mvn/extensions.xml b/tycho-extras/tycho-extras-its/src/test/resources/testsetversionpomless/.mvn/extensions.xml index b890ce96e4..3a98405242 100644 --- a/tycho-extras/tycho-extras-its/src/test/resources/testsetversionpomless/.mvn/extensions.xml +++ b/tycho-extras/tycho-extras-its/src/test/resources/testsetversionpomless/.mvn/extensions.xml @@ -1,8 +1,8 @@ - org.eclipse.tycho.extras - tycho-pomless + org.eclipse.tycho + tycho-build ${tycho-version} diff --git a/tycho-extras/tycho-pomless/pom.xml b/tycho-extras/tycho-pomless/pom.xml index 6f1d307acb..3495b001ed 100644 --- a/tycho-extras/tycho-pomless/pom.xml +++ b/tycho-extras/tycho-pomless/pom.xml @@ -69,6 +69,12 @@ maven-core provided + + org.apache.maven + maven-embedder + ${maven-version} + provided + junit junit diff --git a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoPomlessLifecycleParticipant.java b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoPomlessLifecycleParticipant.java new file mode 100644 index 0000000000..9190d05a78 --- /dev/null +++ b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoPomlessLifecycleParticipant.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2022 Christoph Läubrich and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + * + *******************************************************************************/ +package org.eclipse.tycho.pomless; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import org.apache.maven.AbstractMavenLifecycleParticipant; +import org.apache.maven.MavenExecutionException; +import org.apache.maven.cli.internal.extension.model.CoreExtension; +import org.apache.maven.cli.internal.extension.model.io.xpp3.CoreExtensionsXpp3Reader; +import org.apache.maven.execution.MavenSession; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +@Component(role = AbstractMavenLifecycleParticipant.class, hint = "TychoPomlessLifecycleParticipant") +public class TychoPomlessLifecycleParticipant extends AbstractMavenLifecycleParticipant { + + @Requirement + protected Logger logger; + + @Override + public void afterSessionStart(MavenSession session) throws MavenExecutionException { + session.getUserProperties().setProperty("tycho.mode", "extension"); + File moduleProjectDirectory = session.getRequest().getMultiModuleProjectDirectory(); + if (moduleProjectDirectory != null) { + File extensionsFile = new File(moduleProjectDirectory, ".mvn/extensions.xml"); + CoreExtensionsXpp3Reader parser = new CoreExtensionsXpp3Reader(); + try (InputStream is = new BufferedInputStream(new FileInputStream(extensionsFile))) { + List extensions = parser.read(is).getExtensions(); + for (CoreExtension coreExtension : extensions) { + if ("org.eclipse.tycho.extras".equals(coreExtension.getGroupId()) + && "tycho-pomless".equals(coreExtension.getArtifactId())) { + logger.warn( + "org.eclipse.tycho.extras:tycho-pomless build extension will be replaced in a future version of Tycho by the new org.eclipse.tycho:tycho-build extension."); + logger.warn( + "You can simply change your .mvn/extensions.xml to reference the new extension right now:"); + logger.warn(""); + logger.warn(" org.eclipse.tycho"); + logger.warn(" tycho-build"); + logger.warn(" " + coreExtension.getVersion() + ""); + logger.warn(""); + break; + } + } + + } catch (IOException | XmlPullParserException e) { + // //don't care, we just wan't to inform the user... + } + } + } +}