-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support resolving of target projects from the reactor
Currently resolving an artifact from a target-project fails if the project is not "packed" yet. With a custom workspace reader we can help maven to solve the issue.
- Loading branch information
Showing
2 changed files
with
114 additions
and
21 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
tycho-core/src/main/java/org/eclipse/tycho/core/maven/TargetPlatformWorkspaceReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/******************************************************************************* | ||
* 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.core.maven; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.apache.maven.plugin.LegacySupport; | ||
import org.codehaus.plexus.component.annotations.Component; | ||
import org.codehaus.plexus.component.annotations.Requirement; | ||
import org.eclipse.aether.artifact.Artifact; | ||
import org.eclipse.aether.repository.WorkspaceReader; | ||
import org.eclipse.aether.repository.WorkspaceRepository; | ||
import org.eclipse.tycho.targetplatform.TargetPlatformArtifactResolver; | ||
import org.eclipse.tycho.targetplatform.TargetResolveException; | ||
|
||
/** | ||
* This component allows to resolve target artifacts from the reactor. Maven itself only supports a | ||
* limited way of resolving types in the reactor and do not know how to handle a "target type" | ||
* project. | ||
*/ | ||
@Component(role = WorkspaceReader.class, hint = "TargetPlatformWorkspaceReader") | ||
public class TargetPlatformWorkspaceReader implements WorkspaceReader { | ||
|
||
@Requirement | ||
private TargetPlatformArtifactResolver platformArtifactResolver; | ||
@Requirement | ||
private LegacySupport legacySupport; | ||
private WorkspaceRepository repository; | ||
|
||
public TargetPlatformWorkspaceReader() { | ||
repository = new WorkspaceRepository("tycho-target-platform", null); | ||
} | ||
|
||
@Override | ||
public WorkspaceRepository getRepository() { | ||
return repository; | ||
} | ||
|
||
@Override | ||
public File findArtifact(Artifact artifact) { | ||
if (TargetPlatformArtifactResolver.TARGET_TYPE.equals(artifact.getExtension())) { | ||
try { | ||
Optional<File> targetFile = platformArtifactResolver.getReactorTargetFile(artifact.getGroupId(), | ||
artifact.getArtifactId(), artifact.getVersion(), artifact.getClassifier(), | ||
legacySupport.getSession()); | ||
return targetFile.orElse(null); | ||
} catch (TargetResolveException e) { | ||
// something went wrong, so we can't find the requested artifact here... | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<String> findVersions(Artifact artifact) { | ||
return List.of(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters