Skip to content
Merged
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 @@ -49,7 +49,6 @@
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
Expand All @@ -71,6 +70,7 @@
import org.eclipse.m2e.core.embedder.IComponentLookup;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.internal.Messages;
import org.eclipse.m2e.internal.maven.compat.ExtensionResolutionExceptionFacade;


/**
Expand Down Expand Up @@ -180,14 +180,8 @@ public IMavenPlexusContainer aquire(File basedir) throws Exception {
containerMap.put(canonicalDirectory, plexusContainer);
} catch(ExtensionResolutionException e) {
//TODO how can we create an error marker on the extension file?
CoreExtension extension = e.getExtension();
File file = new File(directory, IMavenPlexusContainer.EXTENSIONS_FILENAME);
throw new PlexusContainerException(
"can't create plexus container for basedir = " + basedir.getAbsolutePath() + " because the extension "
+ extension.getGroupId() + ":" + extension.getArtifactId() + ":" + extension.getVersion()
+ " can't be loaded (defined in "
+ file.getAbsolutePath() + ").",
e);
new ExtensionResolutionExceptionFacade(e).throwForFile(file);
}
}
return plexusContainer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/********************************************************************************
* Copyright (c) 2025 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 is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christoph Läubrich - initial API and implementation
********************************************************************************/

package org.eclipse.m2e.internal.maven.compat;

import java.io.File;

import org.apache.maven.cli.internal.ExtensionResolutionException;
import org.apache.maven.cli.internal.extension.model.CoreExtension;
import org.codehaus.plexus.PlexusContainerException;

/**
* Facade for {@link ExtensionResolutionException} to avoid direct usage that might change in Maven 4.
* This facade wraps the exception and provides a method to throw it as a PlexusContainerException
* with appropriate context information.
*/
public class ExtensionResolutionExceptionFacade {

private final ExtensionResolutionException exception;

public ExtensionResolutionExceptionFacade(ExtensionResolutionException exception) {
if(exception == null) {
throw new IllegalArgumentException("exception cannot be null");
}
this.exception = exception;
}

/**
* Throws a PlexusContainerException with information about the failed extension and the file where it was defined.
*
* @param file the extensions file where the failed extension was defined
* @throws PlexusContainerException always thrown with details about the failed extension
*/
public void throwForFile(File file) throws PlexusContainerException {
CoreExtension extension = exception.getExtension();
throw new PlexusContainerException(
"can't create plexus container because the extension " + extension.getGroupId() + ":"
+ extension.getArtifactId() + ":" + extension.getVersion() + " can't be loaded (defined in "
+ file.getAbsolutePath() + ").",
exception);
}
}
Loading