Native mvnd client

This commit is contained in:
Peter Palaga
2020-06-01 12:23:11 +02:00
parent 4f2c0fb215
commit 82a97ac38b
13 changed files with 315 additions and 99 deletions

View File

@@ -13,7 +13,6 @@ import org.jboss.fuse.mvnd.assertj.MatchInOrderAmongOthers;
import org.jboss.fuse.mvnd.client.Client;
import org.jboss.fuse.mvnd.client.ClientLayout;
import org.jboss.fuse.mvnd.client.ClientOutput;
import org.jboss.fuse.mvnd.client.Layout;
import org.jboss.fuse.mvnd.junit.MvndTest;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@@ -26,10 +25,7 @@ public class MultiModuleTest {
Client client;
@Inject
Layout layout;
@Inject
ClientLayout clientLayout;
ClientLayout layout;
@Test
void cleanInstall() throws IOException {
@@ -45,7 +41,7 @@ public class MultiModuleTest {
}
});
final Path localMavenRepo = clientLayout.getLocalMavenRepository();
final Path localMavenRepo = layout.getLocalMavenRepository();
final Path[] installedJars = {
localMavenRepo.resolve("org/jboss/fuse/mvnd/test/multi-module/multi-module-api/0.0.1-SNAPSHOT/multi-module-api-0.0.1-SNAPSHOT.jar"),
localMavenRepo.resolve("org/jboss/fuse/mvnd/test/multi-module/multi-module-hello/0.0.1-SNAPSHOT/multi-module-hello-0.0.1-SNAPSHOT.jar"),

View File

@@ -12,7 +12,6 @@ import org.jboss.fuse.mvnd.assertj.MatchInOrderAmongOthers;
import org.jboss.fuse.mvnd.client.Client;
import org.jboss.fuse.mvnd.client.ClientLayout;
import org.jboss.fuse.mvnd.client.ClientOutput;
import org.jboss.fuse.mvnd.client.Layout;
import org.jboss.fuse.mvnd.junit.MvndTest;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@@ -26,10 +25,7 @@ public class SingleModuleTest {
Client client;
@Inject
Layout layout;
@Inject
ClientLayout clientLayout;
ClientLayout layout;
@Test
void cleanInstall() throws IOException {
@@ -38,7 +34,7 @@ public class SingleModuleTest {
Files.delete(helloFilePath);
}
final Path installedJar = clientLayout.getLocalMavenRepository().resolve("org/jboss/fuse/mvnd/test/single-module/single-module/0.0.1-SNAPSHOT/single-module-0.0.1-SNAPSHOT.jar");
final Path installedJar = layout.getLocalMavenRepository().resolve("org/jboss/fuse/mvnd/test/single-module/single-module/0.0.1-SNAPSHOT/single-module-0.0.1-SNAPSHOT.jar");
Assertions.assertThat(installedJar).doesNotExist();
final ClientOutput output = Mockito.mock(ClientOutput.class);

View File

@@ -1,14 +1,11 @@
package org.jboss.fuse.mvnd.it;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.Condition;
import org.jboss.fuse.mvnd.assertj.MatchInOrderAmongOthers;
import org.jboss.fuse.mvnd.client.Client;
import org.jboss.fuse.mvnd.client.ClientOutput;

View File

@@ -7,8 +7,8 @@ import javax.inject.Inject;
import org.assertj.core.api.Assertions;
import org.jboss.fuse.mvnd.assertj.MatchInOrderAmongOthers;
import org.jboss.fuse.mvnd.client.Client;
import org.jboss.fuse.mvnd.client.ClientLayout;
import org.jboss.fuse.mvnd.client.ClientOutput;
import org.jboss.fuse.mvnd.client.Layout;
import org.jboss.fuse.mvnd.junit.MvndTest;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@@ -21,7 +21,7 @@ public class VersionTest {
Client client;
@Inject
Layout layout;
ClientLayout layout;
@Test
void version() throws IOException {

View File

@@ -62,12 +62,12 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
f.setAccessible(true);
if (f.getType() == DaemonRegistry.class) {
f.set(testInstance, resource.registry);
} else if (f.getType() == ClientLayout.class) {
f.set(testInstance, resource.layout);
} else if (f.getType() == Layout.class) {
f.set(testInstance, resource.layout);
} else if (f.getType() == Client.class) {
f.set(testInstance, new Client(resource.layout, Optional.of(resource.clientLayout)));
} else if (f.getType() == ClientLayout.class) {
f.set(testInstance, resource.clientLayout);
f.set(testInstance, new Client(resource.layout));
}
}
}
@@ -86,8 +86,7 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
static class MvndResource implements ExtensionContext.Store.CloseableResource {
private final ClientLayout clientLayout;
private final Layout layout;
private final ClientLayout layout;
private final DaemonRegistry registry;
public static MvndResource create(String className, String rawProjectDir) throws IOException {
@@ -125,16 +124,17 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
throw new IllegalStateException(
"The value of mvnd.home system property points at a path that does not exist or is not a directory");
}
final Layout layout = new Layout(Paths.get(System.getProperty("java.home")).toAbsolutePath().normalize(),
mvndHome,
testExecutionDir,
testExecutionDir);
final DaemonRegistry registry = new DaemonRegistry(layout.registry());
final Path localMavenRepository = deleteDir(testDir.resolve("local-maven-repo"));
final Path settingsPath = createSettings(testDir.resolve("settings.xml"));
final ClientLayout clientLayout = new ClientLayout(localMavenRepository, settingsPath);
return new MvndResource(layout, registry, clientLayout);
final ClientLayout layout = new ClientLayout(
mvndHome,
testExecutionDir,
testExecutionDir,
Paths.get(System.getProperty("java.home")).toAbsolutePath().normalize(),
localMavenRepository, settingsPath);
final DaemonRegistry registry = new DaemonRegistry(layout.registry());
return new MvndResource(layout, registry);
}
static Path deleteDir(Path dir) {
@@ -171,11 +171,10 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
return settingsPath;
}
public MvndResource(Layout layout, DaemonRegistry registry, ClientLayout clientLayout) {
public MvndResource(ClientLayout layout, DaemonRegistry registry) {
super();
this.layout = layout;
this.registry = registry;
this.clientLayout = clientLayout;
}
@Override