diff --git a/pom.xml b/pom.xml index 8a6c105925..8ebf1d28b2 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 2.15.0 3.15.0 7.0.0.202409031743-r - 3.9.9 + 4.0.0-beta-4 0.9.0.M3 3.9.6 diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependencyInjector.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependencyInjector.java index 5702c70353..06f654197e 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependencyInjector.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependencyInjector.java @@ -41,9 +41,9 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.codehaus.plexus.logging.Logger; +import org.eclipse.aether.RepositorySystem; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.tycho.ArtifactDescriptor; import org.eclipse.tycho.ArtifactKey; @@ -155,6 +155,7 @@ public static void injectMavenDependencies(MavenProject project, DependencyArtif .flatMap(definition -> definition.getLocations().stream()).filter(MavenGAVLocation.class::isInstance) .map(MavenGAVLocation.class::cast).flatMap(location -> location.getRepositoryReferences().stream()) .toList(); + //FIXME this should be injected in the model building phase so maven can figure it out directly! if (repositoryReferences != null && !repositoryReferences.isEmpty()) { Map repositoryMap = project.getRemoteArtifactRepositories().stream() .collect(Collectors.toMap(MavenDependencyInjector::getId, Function.identity(), (a, b) -> a, @@ -163,19 +164,19 @@ public static void injectMavenDependencies(MavenProject project, DependencyArtif String id = getId(reference); ArtifactRepository artifactRepository = repositoryMap.get(id); if (artifactRepository == null) { - repositoryMap.put(id, - repositorySystem.createArtifactRepository(id, reference.getUrl(), null, null, null)); +// repositoryMap.put(id, +// repositorySystem.createArtifactRepository(id, reference.getUrl(), null, null, null)); } else if (!artifactRepository.getUrl().equals(reference.getUrl())) { logger.warn("Target defines an artifact repository with the ID " + id + " but there is already a repository for that ID mapped to a different URL! (target URL = " + reference.getUrl() + ", existing URL = " + artifactRepository.getUrl()); } } - List artifactRepositories = new ArrayList<>(repositoryMap.values()); - repositorySystem.injectMirror(artifactRepositories, settings.getMirrors()); - repositorySystem.injectProxy(artifactRepositories, settings.getProxies()); - repositorySystem.injectAuthentication(artifactRepositories, settings.getServers()); - project.setRemoteArtifactRepositories(artifactRepositories); +// List artifactRepositories = new ArrayList<>(repositoryMap.values()); +// repositorySystem.injectMirror(artifactRepositories, settings.getMirrors()); +// repositorySystem.injectProxy(artifactRepositories, settings.getProxies()); +// repositorySystem.injectAuthentication(artifactRepositories, settings.getServers()); +// project.setRemoteArtifactRepositories(artifactRepositories); } } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/MavenTargetDefinitionContent.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/MavenTargetDefinitionContent.java index c0737c86ec..d3c1259f84 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/MavenTargetDefinitionContent.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/MavenTargetDefinitionContent.java @@ -43,7 +43,7 @@ import org.apache.commons.io.FilenameUtils; import org.apache.maven.RepositoryUtils; import org.apache.maven.execution.MavenSession; -import org.apache.maven.repository.RepositorySystem; +import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.graph.DependencyNode; diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/MavenTargetLocationFactory.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/MavenTargetLocationFactory.java index 0150dc787d..2ddc7b5274 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/MavenTargetLocationFactory.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/MavenTargetLocationFactory.java @@ -13,9 +13,9 @@ package org.eclipse.tycho.core.resolver; import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; +import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.spi.synccontext.SyncContextFactory; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.tycho.core.MavenDependenciesResolver; diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenDependenciesResolverConfigurer.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenDependenciesResolverConfigurer.java index 2b1e660de9..77afbdf9ee 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenDependenciesResolverConfigurer.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenDependenciesResolverConfigurer.java @@ -16,35 +16,28 @@ import java.io.FileReader; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.MavenProject; -import org.apache.maven.repository.RepositorySystem; 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; +import org.eclipse.aether.RepositorySystem; import org.eclipse.tycho.MavenArtifactRepositoryReference; import org.eclipse.tycho.core.DependencyResolutionException; import org.eclipse.tycho.core.MavenDependenciesResolver; import org.eclipse.tycho.core.MavenModelFacade; -import org.eclipse.tycho.core.maven.MavenArtifactFacade; @Component(role = MavenDependenciesResolver.class) public class MavenDependenciesResolverConfigurer implements MavenDependenciesResolver { @@ -62,68 +55,70 @@ public class MavenDependenciesResolverConfigurer implements MavenDependenciesRes public Collection resolve(String groupId, String artifactId, String version, String packaging, String classifier, Collection scopes, int depth, Collection additionalRepositories, Object session) throws DependencyResolutionException { - Artifact artifact; - if (classifier != null && !classifier.isEmpty()) { - artifact = repositorySystem.createArtifactWithClassifier(groupId, artifactId, version, packaging, - classifier); - } else { - artifact = repositorySystem.createArtifact(groupId, artifactId, version, null, packaging); - } - logger.debug("Resolving " + artifact); - ArtifactResolutionRequest request = new ArtifactResolutionRequest(); - request.setArtifact(artifact); - MavenSession mavenSession = getMavenSession(session); - request.setResolveRoot(true); - request.setOffline(mavenSession.isOffline()); - request.setCollectionFilter(a -> isValidScope(a, scopes)); - request.setResolutionFilter(new ArtifactFilter() { - @Override - public boolean include(Artifact a) { - List trail = a.getDependencyTrail(); - if (logger.isDebugEnabled()) { - logger.debug("[depth=" + trail.size() + ", scope matches =" + isValidScope(a, scopes) + "][" + a - + "][" + trail.stream().collect(Collectors.joining(" >> ")) + "]"); - } - return trail.size() <= depth && isValidScope(a, scopes); - } - }); - request.setLocalRepository(mavenSession.getLocalRepository()); - request.setResolveTransitively(depth > 0); - request.setRemoteRepositories( - getEffectiveRepositories(mavenSession.getCurrentProject(), additionalRepositories, repositorySystem)); - repositorySystem.injectMirror(request.getRemoteRepositories(), mavenSession.getSettings().getMirrors()); - repositorySystem.injectProxy(request.getRemoteRepositories(), mavenSession.getSettings().getProxies()); - repositorySystem.injectAuthentication(request.getRemoteRepositories(), mavenSession.getSettings().getServers()); - ArtifactResolutionResult result = repositorySystem.resolve(request); - if (result.hasExceptions()) { - throw new DependencyResolutionException("resolving " + artifact + " failed!", result.getExceptions()); - } - return result.getArtifacts().stream().filter(a -> a.getFile() != null).map(MavenArtifactFacade::new).toList(); +// Artifact artifact; +// if (classifier != null && !classifier.isEmpty()) { +// artifact = repositorySystem.createArtifactWithClassifier(groupId, artifactId, version, packaging, +// classifier); +// } else { +// artifact = repositorySystem.createArtifact(groupId, artifactId, version, null, packaging); +// } +// logger.debug("Resolving " + artifact); +// ArtifactResolutionRequest request = new ArtifactResolutionRequest(); +// request.setArtifact(artifact); +// MavenSession mavenSession = getMavenSession(session); +// request.setResolveRoot(true); +// request.setOffline(mavenSession.isOffline()); +// request.setCollectionFilter(a -> isValidScope(a, scopes)); +// request.setResolutionFilter(new ArtifactFilter() { +// @Override +// public boolean include(Artifact a) { +// List trail = a.getDependencyTrail(); +// if (logger.isDebugEnabled()) { +// logger.debug("[depth=" + trail.size() + ", scope matches =" + isValidScope(a, scopes) + "][" + a +// + "][" + trail.stream().collect(Collectors.joining(" >> ")) + "]"); +// } +// return trail.size() <= depth && isValidScope(a, scopes); +// } +// }); +// request.setLocalRepository(mavenSession.getLocalRepository()); +// request.setResolveTransitively(depth > 0); +// request.setRemoteRepositories( +// getEffectiveRepositories(mavenSession.getCurrentProject(), additionalRepositories, repositorySystem)); +// repositorySystem.injectMirror(request.getRemoteRepositories(), mavenSession.getSettings().getMirrors()); +// repositorySystem.injectProxy(request.getRemoteRepositories(), mavenSession.getSettings().getProxies()); +// repositorySystem.injectAuthentication(request.getRemoteRepositories(), mavenSession.getSettings().getServers()); +// ArtifactResolutionResult result = repositorySystem.resolve(request); +// if (result.hasExceptions()) { +// throw new DependencyResolutionException("resolving " + artifact + " failed!", result.getExceptions()); +// } +// return result.getArtifacts().stream().filter(a -> a.getFile() != null).map(MavenArtifactFacade::new).toList(); + return null; } @SuppressWarnings("deprecation") public static List getEffectiveRepositories(MavenProject project, Collection additionalRepositories, RepositorySystem repositorySystem) { List projectRepositories; - if (project == null) { - try { - projectRepositories = List.of(repositorySystem.createDefaultRemoteRepository()); - } catch (InvalidRepositoryException e) { - projectRepositories = List.of(); - } - } else { - projectRepositories = project.getRemoteArtifactRepositories(); - } - - if (additionalRepositories != null && !additionalRepositories.isEmpty()) { - List repositories = new ArrayList<>(projectRepositories); - for (MavenArtifactRepositoryReference reference : additionalRepositories) { - repositories.add(repositorySystem.createArtifactRepository(reference.getId(), reference.getUrl(), null, - null, null)); - } - return repositorySystem.getEffectiveRepositories(repositories); - } - return projectRepositories; +// if (project == null) { +// try { +// projectRepositories = List.of(repositorySystem.createDefaultRemoteRepository()); +// } catch (InvalidRepositoryException e) { +// projectRepositories = List.of(); +// } +// } else { +// projectRepositories = project.getRemoteArtifactRepositories(); +// } +// +// if (additionalRepositories != null && !additionalRepositories.isEmpty()) { +// List repositories = new ArrayList<>(projectRepositories); +// for (MavenArtifactRepositoryReference reference : additionalRepositories) { +// repositories.add(repositorySystem.createArtifactRepository(reference.getId(), reference.getUrl(), null, +// null, null)); +// } +// return repositorySystem.getEffectiveRepositories(repositories); +// } +// return projectRepositories; + return null; } protected boolean isValidScope(Artifact artifact, Collection scopes) { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2DependencyResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2DependencyResolver.java index 2b367e1ebb..b2eeaefcfc 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2DependencyResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2DependencyResolver.java @@ -38,13 +38,13 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.MavenProject; -import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; +import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.metadata.IRequirement; diff --git a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java index 31aa5dc1f9..157630ae13 100644 --- a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java +++ b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java @@ -43,6 +43,7 @@ import org.apache.maven.model.PluginExecution; import org.apache.maven.model.building.FileModelSource; import org.apache.maven.model.building.ModelProcessor; +import org.apache.maven.model.io.ModelParseException; import org.apache.maven.model.io.ModelReader; import org.apache.maven.model.io.ModelWriter; import org.codehaus.plexus.PlexusContainer; @@ -150,6 +151,11 @@ public Model read(Reader input, Map options) throws IOException { return read(input, file, options); } + @Override + public Model read(Path input, Map options) throws IOException, ModelParseException { + return read(input.toFile(), options); + } + private Model read(Reader artifactReader, Path artifactFile, Map options) throws IOException { Model model = new Model(); model.setModelVersion("4.0.0"); 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 deleted file mode 100644 index 0081b2070e..0000000000 --- a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoPomlessLifecycleParticipant.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * 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.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 { - File moduleProjectDirectory = session.getRequest().getMultiModuleProjectDirectory(); - if (moduleProjectDirectory != null) { - File extensionsFile = new File(moduleProjectDirectory, ".mvn/extensions.xml"); - try (InputStream is = new FileInputStream(extensionsFile)) { - List extensions = new CoreExtensionsXpp3Reader().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... - } - } - } -} diff --git a/tycho-spi/pom.xml b/tycho-spi/pom.xml index 68a891030a..1835bf87ea 100644 --- a/tycho-spi/pom.xml +++ b/tycho-spi/pom.xml @@ -30,6 +30,13 @@ tycho-api ${project.version} + + + + org.codehaus.plexus + plexus-component-annotations + 2.2.0 + diff --git a/tycho-testing-harness/pom.xml b/tycho-testing-harness/pom.xml index 9236065363..25203b0434 100644 --- a/tycho-testing-harness/pom.xml +++ b/tycho-testing-harness/pom.xml @@ -10,7 +10,8 @@ - Sonatype Inc. - initial API and implementation --> - 4.0.0 @@ -68,6 +69,11 @@ sisu-osgi-api ${project.version} + + com.google.inject + guice + 7.0.0 +