-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maven Resolver: initialize Maven properly, especially the local repos…
…itory The `BootstrapMavenContext.newRepositorySystemSession()` method is now a lot closer to `DefaultRepositorySystemSessionFactory.newRepositorySession()`, especially around how it initializes the `LocalRepositoryManager`. It is now done _after_ setting up the config properties on the `RepositorySystemSession`, which has also been fixed (to include the properties of all active profiles, including those in `settings.xml`). Furhter, this commit renames 2 files to match the name of the (non-`public`) class declared in them, and fixes self type emulation in `BootstrapMavenContextConfig`.
- Loading branch information
Showing
6 changed files
with
127 additions
and
85 deletions.
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
...lver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SplitLocalRepositoryTest.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,31 @@ | ||
package io.quarkus.bootstrap.resolver.maven.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.eclipse.aether.artifact.DefaultArtifact; | ||
import org.eclipse.aether.repository.LocalRepositoryManager; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; | ||
|
||
public class SplitLocalRepositoryTest extends BootstrapMavenContextTestBase { | ||
@Test | ||
public void test() throws Exception { | ||
BootstrapMavenContext mvn = bootstrapMavenContextForProject("custom-settings/split-local-repository"); | ||
LocalRepositoryManager lrm = mvn.getRepositorySystemSession().getLocalRepositoryManager(); | ||
|
||
assertEquals("installed/releases/foo/bar/1.0/bar-1.0.jar", | ||
lrm.getPathForLocalArtifact(new DefaultArtifact("foo:bar:1.0"))); | ||
assertEquals("installed/snapshots/foo/bar/1.0-SNAPSHOT/bar-1.0-SNAPSHOT.jar", | ||
lrm.getPathForLocalArtifact(new DefaultArtifact("foo:bar:1.0-SNAPSHOT"))); | ||
|
||
RemoteRepository remoteRepo = new RemoteRepository.Builder("remote-repo", "default", "https://example.com/repo/") | ||
.build(); | ||
|
||
assertEquals("cached/releases/foo/bar/1.0/bar-1.0.jar", | ||
lrm.getPathForRemoteArtifact(new DefaultArtifact("foo:bar:1.0"), remoteRepo, null)); | ||
assertEquals("cached/snapshots/foo/bar/1.0-SNAPSHOT/bar-1.0-SNAPSHOT.jar", | ||
lrm.getPathForRemoteArtifact(new DefaultArtifact("foo:bar:1.0-SNAPSHOT"), remoteRepo, null)); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...rap/maven-resolver/src/test/resources/custom-settings/split-local-repository/settings.xml
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" | ||
xmlns="http://maven.apache.org/SETTINGS/1.1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<profiles> | ||
<profile> | ||
<id>split-local-repo</id> | ||
<properties> | ||
<aether.enhancedLocalRepository.split>true</aether.enhancedLocalRepository.split> | ||
<aether.enhancedLocalRepository.splitLocal>true</aether.enhancedLocalRepository.splitLocal> | ||
<aether.enhancedLocalRepository.splitRemote>true</aether.enhancedLocalRepository.splitRemote> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
<activeProfiles> | ||
<activeProfile>split-local-repo</activeProfile> | ||
</activeProfiles> | ||
</settings> |