Skip to content

Commit

Permalink
Add deprecation notice regarding tycho.mode=maven
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Jan 28, 2024
1 parent dc94fbf commit 98123cb
Showing 1 changed file with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -104,6 +105,8 @@ public class TychoMavenLifecycleParticipant extends AbstractMavenLifecyclePartic
@Requirement
TychoProjectManager projectManager;

private boolean warnedAboutTychoMode;

public TychoMavenLifecycleParticipant() {
// needed for plexus
}
Expand Down Expand Up @@ -361,11 +364,38 @@ private void validateUniqueBaseDirs(List<MavenProject> projects) throws MavenExe
private static final Set<String> 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) {
Expand Down

0 comments on commit 98123cb

Please sign in to comment.