-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile compiler bridge from sources, close #363
Motivation: Scala compiler doesn't provide binary compatibility. Binary compatibility was broken in 2.13.1 so incremental compiler crashes. Modifications: Recompile the compiler-bridge from sources instead of using the binary on maven central. Cache it in `~/.sbt/1.0/zinc/org.scala-sbt` by default (configurable). Result: scala-maven-plugin support compiling in Scala 2.13.1.
- Loading branch information
Showing
5 changed files
with
261 additions
and
38 deletions.
There are no files selected for viewing
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
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,48 @@ | ||
package scala_maven; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; | ||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.repository.RepositorySystem; | ||
|
||
import java.util.Set; | ||
|
||
public class MavenArtifactResolver { | ||
|
||
private final RepositorySystem repositorySystem; | ||
private final MavenSession session; | ||
|
||
public MavenArtifactResolver(RepositorySystem repositorySystem, MavenSession session) { | ||
this.repositorySystem = repositorySystem; | ||
this.session = session; | ||
} | ||
|
||
public Artifact getJar(String groupId, String artifactId, String version, String classifier) { | ||
Artifact artifact = createJarArtifact(groupId, artifactId, version, classifier); | ||
return resolve(artifact, false).iterator().next(); | ||
} | ||
|
||
public Set<Artifact> getJarAndDependencies(String groupId, String artifactId, String version, String classifier) { | ||
Artifact artifact = createJarArtifact(groupId, artifactId, version, classifier); | ||
return resolve(artifact, true); | ||
} | ||
|
||
private Artifact createJarArtifact(String groupId, String artifactId, String version, String classifier) { | ||
return classifier == null ? repositorySystem.createArtifact(groupId, artifactId, version, ScalaMojoSupport.JAR) | ||
: repositorySystem.createArtifactWithClassifier(groupId, artifactId, version, ScalaMojoSupport.JAR, | ||
classifier); | ||
} | ||
|
||
private Set<Artifact> resolve(Artifact artifact, boolean transitively) { | ||
ArtifactResolutionRequest request = new ArtifactResolutionRequest() // | ||
.setArtifact(artifact) // | ||
.setResolveRoot(true) // | ||
.setResolveTransitively(transitively) // | ||
.setServers(session.getRequest().getServers()) // | ||
.setMirrors(session.getRequest().getMirrors()) // | ||
.setProxies(session.getRequest().getProxies()) // | ||
.setLocalRepository(session.getLocalRepository()) // | ||
.setRemoteRepositories(session.getCurrentProject().getRemoteArtifactRepositories()); | ||
return repositorySystem.resolve(request).getArtifacts(); | ||
} | ||
} |
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
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
Oops, something went wrong.