From a8d5335685f5ff7d3b4f3697d31e641d94878b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 28 Jan 2024 15:17:40 +0100 Subject: [PATCH] Add deprecation notice regarding tycho.mode=maven (cherry picked from commit 98123cbd3e32e736ad0e23e8d8608fb6c561cbbb) --- .../maven/TychoMavenLifecycleParticipant.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java index 47b2d56038..e3126fbe2d 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java @@ -34,6 +34,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -104,6 +105,8 @@ public class TychoMavenLifecycleParticipant extends AbstractMavenLifecyclePartic @Requirement TychoProjectManager projectManager; + private boolean warnedAboutTychoMode; + public TychoMavenLifecycleParticipant() { // needed for plexus } @@ -361,11 +364,38 @@ private void validateUniqueBaseDirs(List projects) throws MavenExe private static final Set CLEAN_PHASES = Set.of("pre-clean", "clean", "post-clean"); private boolean disableLifecycleParticipation(MavenSession session) { + return isMavenMode(session) || isM2E(session) || isCleanOnly(session); + } + + private boolean isCleanOnly(MavenSession session) { + // disable for 'clean-only' builds. Consider that Maven can be invoked without explicit goals, if default goals are specified + return !session.getGoals().isEmpty() && CLEAN_PHASES.containsAll(session.getGoals()); + } + + private boolean isM2E(MavenSession session) { + return session.getUserProperties().containsKey("m2e.version"); + } + + private boolean isMavenMode(MavenSession session) { // command line property to disable Tycho lifecycle participant - return "maven".equals(session.getUserProperties().get("tycho.mode")) - || session.getUserProperties().containsKey("m2e.version") - // disable for 'clean-only' builds. Consider that Maven can be invoked without explicit goals, if default goals are specified - || (!session.getGoals().isEmpty() && CLEAN_PHASES.containsAll(session.getGoals())); + if ("maven".equals(session.getUserProperties().get(TychoConstants.SESSION_PROPERTY_TYCHO_MODE))) { + synchronized (TychoMavenLifecycleParticipant.class) { + if (!warnedAboutTychoMode) { + warnedAboutTychoMode = true; + log.warn("######## IMPORTANT #######"); + log.warn("Usage of " + TychoConstants.SESSION_PROPERTY_TYCHO_MODE + + "=maven is deprecated and will be removed in later Tycho versions, see https://github.com/eclipse-tycho/tycho/issues/676"); + log.warn("######## IMPORTANT #######"); + try { + //to give user change to see the message.... + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e) { + } + } + } + return true; + } + return false; } private void configureComponents(MavenSession session) {