Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static UnaryOperator<String> or(UnaryOperator<String>... callbacks) {
public static int toMavenExecutionRequestLoggingLevel(Slf4jConfiguration.Level level) {
requireNonNull(level, "level");
return switch (level) {
case DEBUG -> MavenExecutionRequest.LOGGING_LEVEL_DEBUG;
case TRACE, DEBUG -> MavenExecutionRequest.LOGGING_LEVEL_DEBUG;
case INFO -> MavenExecutionRequest.LOGGING_LEVEL_INFO;
case ERROR -> MavenExecutionRequest.LOGGING_LEVEL_ERROR;
};
Expand All @@ -124,7 +124,7 @@ public static int toMavenExecutionRequestLoggingLevel(Slf4jConfiguration.Level l
public static int toPlexusLoggingLevel(Slf4jConfiguration.Level level) {
requireNonNull(level, "level");
return switch (level) {
case DEBUG -> Logger.LEVEL_DEBUG;
case TRACE, DEBUG -> Logger.LEVEL_DEBUG;
case INFO -> Logger.LEVEL_INFO;
case ERROR -> Logger.LEVEL_ERROR;
};
Expand All @@ -148,4 +148,4 @@ public static Path findMandatoryRoot(Path topDirectory) {
ServiceLoader.load(RootLocator.class).iterator().next().findMandatoryRoot(topDirectory))
.orElseThrow());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public interface Slf4jConfiguration {
* Level
*/
enum Level {
TRACE,
DEBUG,
INFO,
ERROR
Expand All @@ -45,4 +46,4 @@ enum Level {
* Activate logging implementation configuration (if necessary).
*/
void activate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class MavenSimpleConfiguration extends BaseSlf4jConfiguration {
public void setRootLoggerLevel(Level level) {
String value =
switch (level) {
case TRACE -> "trace";
case DEBUG -> "debug";
case INFO -> "info";
case ERROR -> "error";
Expand All @@ -58,4 +59,4 @@ public void activate() {
mlf.reconfigure();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public void setRootLoggerLevel(Level level) {
// Simulate what MavenSimpleConfiguration does
String value =
switch (level) {
case TRACE -> "trace";
case DEBUG -> "debug";
case INFO -> "info";
case ERROR -> "error";
Expand All @@ -170,4 +171,4 @@ public void activate() {
// no-op for test
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private ClassRealm newRealm(String id) {
try {
ClassRealm classRealm = world.newRealm(realmId, null);

logger.debug("Created new class realm {}", realmId);
logger.trace("Created new class realm {}", realmId);

return classRealm;
} catch (DuplicateRealmException e) {
Expand Down Expand Up @@ -177,8 +177,8 @@ private ClassRealm createRealm(
for (Artifact artifact : artifacts) {
if (!isProvidedArtifact(artifact, v4api) && artifact.getFile() != null) {
constituents.add(new ArtifactClassRealmConstituent(artifact));
} else if (logger.isDebugEnabled()) {
logger.debug(" Excluded: {}", getId(artifact));
} else if (logger.isTraceEnabled()) {
logger.trace(" Excluded: {}", getId(artifact));
}
}
}
Expand Down Expand Up @@ -314,14 +314,14 @@ private void callDelegates(
}

private void populateRealm(ClassRealm classRealm, List<ClassRealmConstituent> constituents) {
logger.debug("Populating class realm {}", classRealm.getId());
logger.trace("Populating class realm {}", classRealm.getId());

for (ClassRealmConstituent constituent : constituents) {
File file = constituent.getFile();

if (logger.isDebugEnabled()) {
if (logger.isTraceEnabled()) {
String id = getId(constituent);
logger.debug(" Included: {}", id);
logger.trace(" Included: {}", id);
}

try {
Expand All @@ -335,23 +335,23 @@ private void populateRealm(ClassRealm classRealm, List<ClassRealmConstituent> co

private void wireRealm(ClassRealm classRealm, List<String> parentImports, Map<String, ClassLoader> foreignImports) {
if (foreignImports != null && !foreignImports.isEmpty()) {
logger.debug("Importing foreign packages into class realm {}", classRealm.getId());
logger.trace("Importing foreign packages into class realm {}", classRealm.getId());

for (Map.Entry<String, ClassLoader> entry : foreignImports.entrySet()) {
ClassLoader importedRealm = entry.getValue();
String imp = entry.getKey();

logger.debug(" Imported: {} < {}", imp, getId(importedRealm));
logger.trace(" Imported: {} < {}", imp, getId(importedRealm));

classRealm.importFrom(importedRealm, imp);
}
}

if (parentImports != null && !parentImports.isEmpty()) {
logger.debug("Importing parent packages into class realm {}", classRealm.getId());
logger.trace("Importing parent packages into class realm {}", classRealm.getId());

for (String imp : parentImports) {
logger.debug(" Imported: {} < {}", imp, getId(classRealm.getParentClassLoader()));
logger.trace(" Imported: {} < {}", imp, getId(classRealm.getParentClassLoader()));

classRealm.importFromParent(imp);
}
Expand All @@ -364,4 +364,4 @@ private static Object getId(ClassLoader classLoader) {
}
return classLoader;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,53 +49,53 @@ public class LifecycleDebugLogger {
private final Logger logger = LoggerFactory.getLogger(getClass());

public void debug(String s) {
logger.debug(s);
logger.trace(s);
}

public void info(String s) {
logger.info(s);
}

public void debugReactorPlan(ProjectBuildList projectBuilds) {
if (!logger.isDebugEnabled()) {
if (!logger.isTraceEnabled()) {
return;
}

logger.debug("=== REACTOR BUILD PLAN ================================================");
logger.trace("=== REACTOR BUILD PLAN ================================================");

for (Iterator<ProjectSegment> it = projectBuilds.iterator(); it.hasNext(); ) {
ProjectSegment projectBuild = it.next();

logger.debug("Project: " + projectBuild.getProject().getId());
logger.debug("Tasks: " + projectBuild.getTaskSegment().getTasks());
logger.debug("Style: " + (projectBuild.getTaskSegment().isAggregating() ? "Aggregating" : "Regular"));
logger.trace("Project: " + projectBuild.getProject().getId());
logger.trace("Tasks: " + projectBuild.getTaskSegment().getTasks());
logger.trace("Style: " + (projectBuild.getTaskSegment().isAggregating() ? "Aggregating" : "Regular"));

if (it.hasNext()) {
logger.debug("-----------------------------------------------------------------------");
logger.trace("-----------------------------------------------------------------------");
}
}

logger.debug("=======================================================================");
logger.trace("=======================================================================");
}

public void debugProjectPlan(MavenProject currentProject, MavenExecutionPlan executionPlan) {
if (!logger.isDebugEnabled()) {
if (!logger.isTraceEnabled()) {
return;
}

logger.debug("=== PROJECT BUILD PLAN ================================================");
logger.debug("Project: " + BuilderCommon.getKey(currentProject));
logger.trace("=== PROJECT BUILD PLAN ================================================");
logger.trace("Project: " + BuilderCommon.getKey(currentProject));

debugDependencyRequirements(executionPlan.getMojoExecutions());

logger.debug("Repositories (dependencies): " + currentProject.getRemoteProjectRepositories());
logger.debug("Repositories (plugins) : " + currentProject.getRemotePluginRepositories());
logger.trace("Repositories (dependencies): " + currentProject.getRemoteProjectRepositories());
logger.trace("Repositories (plugins) : " + currentProject.getRemotePluginRepositories());

for (ExecutionPlanItem mojoExecution : executionPlan) {
debugMojoExecution(mojoExecution.getMojoExecution());
}

logger.debug("=======================================================================");
logger.trace("=======================================================================");
}

private void debugMojoExecution(MojoExecution mojoExecution) {
Expand All @@ -106,23 +106,23 @@ private void debugMojoExecution(MojoExecution mojoExecution) {
Map<String, List<MojoExecution>> forkedExecutions = mojoExecution.getForkedExecutions();
if (!forkedExecutions.isEmpty()) {
for (Map.Entry<String, List<MojoExecution>> fork : forkedExecutions.entrySet()) {
logger.debug("--- init fork of " + fork.getKey() + " for " + mojoExecId + " ---");
logger.trace("--- init fork of " + fork.getKey() + " for " + mojoExecId + " ---");

debugDependencyRequirements(fork.getValue());

for (MojoExecution forkedExecution : fork.getValue()) {
debugMojoExecution(forkedExecution);
}

logger.debug("--- exit fork of " + fork.getKey() + " for " + mojoExecId + " ---");
logger.trace("--- exit fork of " + fork.getKey() + " for " + mojoExecId + " ---");
}
}

logger.debug("-----------------------------------------------------------------------");
logger.debug("Goal: " + mojoExecId);
logger.debug(
logger.trace("-----------------------------------------------------------------------");
logger.trace("Goal: " + mojoExecId);
logger.trace(
"Style: " + (mojoExecution.getMojoDescriptor().isAggregator() ? "Aggregating" : "Regular"));
logger.debug("Configuration: " + mojoExecution.getConfiguration());
logger.trace("Configuration: " + mojoExecution.getConfiguration());
}

private void debugDependencyRequirements(List<MojoExecution> mojoExecutions) {
Expand All @@ -143,7 +143,7 @@ private void debugDependencyRequirements(List<MojoExecution> mojoExecutions) {
}
}

logger.debug("Dependencies (collect): " + scopesToCollect);
logger.debug("Dependencies (resolve): " + scopesToResolve);
logger.trace("Dependencies (collect): " + scopesToCollect);
logger.trace("Dependencies (resolve): " + scopesToResolve);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void multiThreadedProjectTaskSegmentBuild(
// schedule independent projects (ordered by critical path priority)
for (MavenProject mavenProject : analyzer.getRootSchedulableBuilds()) {
ProjectSegment projectSegment = projectBuildList.get(mavenProject);
logger.debug("Scheduling: {}", projectSegment.getProject());
logger.trace("Scheduling: {}", projectSegment.getProject());
Callable<ProjectSegment> cb =
createBuildCallable(rootSession, projectSegment, reactorContext, taskSegment, duplicateArtifactIds);
service.submit(cb);
Expand All @@ -155,7 +155,7 @@ private void multiThreadedProjectTaskSegmentBuild(
analyzer.markAsFinished(projectBuild.getProject());
for (MavenProject mavenProject : newItemsThatCanBeBuilt) {
ProjectSegment scheduledDependent = projectBuildList.get(mavenProject);
logger.debug("Scheduling: {}", scheduledDependent);
logger.trace("Scheduling: {}", scheduledDependent);
Callable<ProjectSegment> cb = createBuildCallable(
rootSession, scheduledDependent, reactorContext, taskSegment, duplicateArtifactIds);
service.submit(cb);
Expand Down Expand Up @@ -198,4 +198,4 @@ private Callable<ProjectSegment> createBuildCallable(
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ private void processStep(BuildStep step) {
if (shouldExecute && anyPredecessorFailed) {
// We'll run the step but mark it as SKIPPED instead of SCHEDULED
if (step.status.compareAndSet(CREATED, SKIPPED)) {
logger.debug(
logger.trace(
"Running after:* step {} for cleanup but marking it as SKIPPED because a predecessor failed",
step);
executor.execute(() -> {
Expand All @@ -405,7 +405,7 @@ private void processStep(BuildStep step) {
step.status.compareAndSet(SKIPPED, FAILED);
// Store the exception in the step for handling in the TEARDOWN phase
step.exception = e;
logger.debug("Stored exception for step {} to be handled in TEARDOWN phase", step, e);
logger.trace("Stored exception for step {} to be handled in TEARDOWN phase", step, e);
// Let the scheduler handle after:* phases and TEARDOWN in the next cycle
executePlan();
}
Expand Down Expand Up @@ -443,7 +443,7 @@ private void processStep(BuildStep step) {

// Store the exception in the step for handling in the TEARDOWN phase
step.exception = e;
logger.debug("Stored exception for step {} to be handled in TEARDOWN phase", step, e);
logger.trace("Stored exception for step {} to be handled in TEARDOWN phase", step, e);

// Let the scheduler handle after:* phases and TEARDOWN in the next cycle
executePlan();
Expand All @@ -453,18 +453,18 @@ private void processStep(BuildStep step) {
// Skip the step and provide a specific reason
if (!shouldExecute) {
if (status.isHalted()) {
logger.debug("Skipping step {} because the build is halted", step);
logger.trace("Skipping step {} because the build is halted", step);
} else if (status.isBlackListed(step.project)) {
logger.debug("Skipping step {} because the project is blacklisted", step);
logger.trace("Skipping step {} because the project is blacklisted", step);
} else if (TEARDOWN.equals(step.name)) {
// This should never happen given we always process TEARDOWN steps
logger.warn("Unexpected skipping of TEARDOWN step {}", step);
} else {
logger.debug("Skipping step {} because a dependency has failed", step);
logger.trace("Skipping step {} because a dependency has failed", step);
}
} else {
// Skip because predecessors failed or were skipped
logger.debug(
logger.trace(
"Skipping step {} because one or more predecessors did not execute successfully", step);
}
// Recursively call executePlan to process steps that depend on this one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import org.apache.maven.plugin.prefix.PluginPrefixRequest;
import org.apache.maven.plugin.prefix.PluginPrefixResolver;
import org.apache.maven.plugin.prefix.PluginPrefixResult;
import org.apache.maven.plugin.version.DefaultPluginVersionRequest;
import org.apache.maven.plugin.version.PluginVersionResolver;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
Expand Down Expand Up @@ -79,23 +77,18 @@ public class DefaultPluginPrefixResolver implements PluginPrefixResolver {
private final BuildPluginManager pluginManager;
private final RepositorySystem repositorySystem;
private final MetadataReader metadataReader;
private final PluginVersionResolver pluginVersionResolver;

@Inject
public DefaultPluginPrefixResolver(
BuildPluginManager pluginManager,
RepositorySystem repositorySystem,
MetadataReader metadataReader,
PluginVersionResolver pluginVersionResolver) {
BuildPluginManager pluginManager, RepositorySystem repositorySystem, MetadataReader metadataReader) {
this.pluginManager = pluginManager;
this.repositorySystem = repositorySystem;
this.metadataReader = metadataReader;
this.pluginVersionResolver = pluginVersionResolver;
}

@Override
public PluginPrefixResult resolve(PluginPrefixRequest request) throws NoPluginFoundForPrefixException {
logger.debug("Resolving plugin prefix {} from {}", request.getPrefix(), request.getPluginGroups());
logger.trace("Resolving plugin prefix {} from {}", request.getPrefix(), request.getPluginGroups());

Model pom = request.getPom();
Build build = pom != null ? pom.getBuild() : null;
Expand Down Expand Up @@ -139,7 +132,7 @@ public PluginPrefixResult resolve(PluginPrefixRequest request) throws NoPluginFo
request.getRepositorySession().getLocalRepository(),
request.getRepositories());
} else {
logger.debug(
logger.trace(
"Resolved plugin prefix {} to {}:{} from repository {}",
request.getPrefix(),
result.getGroupId(),
Expand Down Expand Up @@ -174,13 +167,6 @@ private PluginPrefixResult resolveFromProject(
private PluginPrefixResult doResolveFromProject(PluginPrefixRequest request, Collection<Plugin> plugins) {
for (Plugin plugin : plugins) {
try {
if (plugin.getVersion() == null) {
DefaultPluginVersionRequest versionRequest = new DefaultPluginVersionRequest(
plugin, request.getRepositorySession(), request.getRepositories())
.setPom(request.getPom());
plugin.setVersion(
pluginVersionResolver.resolve(versionRequest).getVersion());
}
PluginDescriptor pluginDescriptor =
pluginManager.loadPlugin(plugin, request.getRepositories(), request.getRepositorySession());

Expand Down Expand Up @@ -321,4 +307,4 @@ private void invalidMetadata(
listener.metadataInvalid(event.build());
}
}
}
}
Loading