use of org.jboss.galleon.cli.config.mvn.MavenConfig in project galleon by wildfly.
the class MavenConfigTestCase method testRepository.
@Test
public void testRepository() throws Exception {
MavenConfig config = cli.getSession().getPmConfiguration().getMavenConfig();
String name = "foofoo";
String name2 = "barbar";
String url = "http://foo";
try {
cli.execute("maven add-repository --name=" + name + " --url=" + url + " --release-update-policy=foo");
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
try {
cli.execute("maven add-repository --name=" + name + " --url=" + url + " --snapshot-update-policy=foo");
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
cli.execute("maven add-repository --name=" + name + " --url=" + url);
cli.execute("maven add-repository --name=" + name2 + " --url=" + url + " --snapshot-update-policy=always " + "--release-update-policy=never --enable-snapshot=true --enable-release=false");
checkRepositories(config, url, name, name2);
checkRepositories(Configuration.parse().getMavenConfig(), url, name, name2);
try {
cli.execute("maven remove-repository XXX");
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
cli.execute("maven get-info");
Assert.assertTrue(cli.getOutput().contains(name));
Assert.assertTrue(cli.getOutput().contains(name2));
cli.execute("maven remove-repository " + name);
cli.execute("maven remove-repository " + name2);
checkNoRepositories(config, name, name2);
checkNoRepositories(Configuration.parse().getMavenConfig(), name, name2);
}
use of org.jboss.galleon.cli.config.mvn.MavenConfig in project galleon by wildfly.
the class MavenConfigTestCase method testEnable.
@Test
public void testEnable() throws Exception {
MavenConfig config = cli.getSession().getPmConfiguration().getMavenConfig();
boolean enableSnapshot = config.isSnapshotEnabled();
boolean enableRelease = config.isReleaseEnabled();
try {
cli.execute("maven enable-snapshot foo");
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
try {
cli.execute("maven enable-release bar");
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
cli.execute("maven enable-snapshot " + !enableSnapshot);
cli.execute("maven enable-release " + !enableRelease);
Assert.assertEquals(!enableSnapshot, config.isSnapshotEnabled());
Assert.assertEquals(!enableRelease, config.isReleaseEnabled());
cli.execute("maven get-info");
Assert.assertTrue(cli.getOutput().contains("release=" + !enableRelease));
Assert.assertTrue(cli.getOutput().contains("snapshot=" + !enableSnapshot));
cli.execute("maven reset-snapshot");
cli.execute("maven reset-release");
Assert.assertEquals(enableSnapshot, config.isSnapshotEnabled());
Assert.assertEquals(enableRelease, config.isReleaseEnabled());
}
use of org.jboss.galleon.cli.config.mvn.MavenConfig in project galleon by wildfly.
the class MavenConfigTestCase method testUpdatePolicies.
@Test
public void testUpdatePolicies() throws Exception {
MavenConfig config = cli.getSession().getPmConfiguration().getMavenConfig();
String defaultRelease = config.getDefaultReleasePolicy();
String defaultSnapshot = config.getDefaultSnapshotPolicy();
String snapshotPolicy = "interval:700";
String releasePolicy = "never";
try {
cli.execute("maven set-release-update-policy interval:");
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
try {
cli.execute("maven set-snapshot-update-policy interval:");
throw new Exception("Should have failed");
} catch (CommandException ex) {
// XXX OK
}
cli.execute("maven set-snapshot-update-policy " + snapshotPolicy);
cli.execute("maven set-release-update-policy " + releasePolicy);
cli.execute("maven get-info");
Assert.assertTrue(cli.getOutput().contains("snapshotUpdatePolicy=" + snapshotPolicy));
Assert.assertTrue(cli.getOutput().contains("releaseUpdatePolicy=" + releasePolicy));
Assert.assertEquals(snapshotPolicy, config.getDefaultSnapshotPolicy());
Assert.assertEquals(releasePolicy, config.getDefaultReleasePolicy());
Assert.assertEquals(snapshotPolicy, Configuration.parse().getMavenConfig().getDefaultSnapshotPolicy());
Assert.assertEquals(releasePolicy, Configuration.parse().getMavenConfig().getDefaultReleasePolicy());
cli.execute("maven reset-snapshot-update-policy");
cli.execute("maven reset-release-update-policy");
Assert.assertEquals(defaultSnapshot, config.getDefaultSnapshotPolicy());
Assert.assertEquals(defaultRelease, config.getDefaultReleasePolicy());
Assert.assertEquals(defaultSnapshot, Configuration.parse().getMavenConfig().getDefaultSnapshotPolicy());
Assert.assertEquals(defaultRelease, Configuration.parse().getMavenConfig().getDefaultReleasePolicy());
}
use of org.jboss.galleon.cli.config.mvn.MavenConfig in project galleon by wildfly.
the class MavenGetInfo method runCommand.
@Override
protected void runCommand(PmCommandInvocation session) throws CommandExecutionException {
Table t = new Table(Headers.CONFIGURATION_ITEM, Headers.VALUE);
MavenConfig config = session.getPmSession().getPmConfiguration().getMavenConfig();
t.addLine("Maven xml settings", (config.getSettings() == null ? "No settings file set" : config.getSettings().normalize().toString()));
t.addLine("Local repository", config.getLocalRepository().normalize().toString());
t.addLine("Default release policy", config.getDefaultReleasePolicy());
t.addLine("Default snapshot policy", config.getDefaultSnapshotPolicy());
t.addLine("Enable release", "" + config.isReleaseEnabled());
t.addLine("Enable snapshot", "" + config.isSnapshotEnabled());
t.addLine("Offline", "" + config.isOffline());
Cell repositories = new Cell();
Cell title = new Cell("Remote repositories");
if (config.getRemoteRepositories().isEmpty()) {
repositories.addLine("None");
} else {
for (MavenRemoteRepository rep : session.getPmSession().getPmConfiguration().getMavenConfig().getRemoteRepositories()) {
repositories.addLine(rep.getName());
repositories.addLine(" url=" + rep.getUrl());
repositories.addLine(" type=" + rep.getType());
repositories.addLine(" release=" + (rep.getEnableRelease() == null ? config.isReleaseEnabled() : rep.getEnableRelease()));
repositories.addLine(" releaseUpdatePolicy=" + (rep.getReleaseUpdatePolicy() == null ? config.getDefaultReleasePolicy() : rep.getReleaseUpdatePolicy()));
repositories.addLine(" snapshot=" + (rep.getEnableSnapshot() == null ? config.isSnapshotEnabled() : rep.getEnableSnapshot()));
repositories.addLine(" snapshotUpdatePolicy=" + (rep.getSnapshotUpdatePolicy() == null ? config.getDefaultSnapshotPolicy() : rep.getSnapshotUpdatePolicy()));
}
}
t.addCellsLine(title, repositories);
t.sort(Table.SortType.ASCENDANT);
session.println(t.build());
}
use of org.jboss.galleon.cli.config.mvn.MavenConfig in project galleon by wildfly.
the class MavenConfigTestCase method testSettingsFile.
@Test
public void testSettingsFile() throws Exception {
MavenConfig config = cli.getSession().getPmConfiguration().getMavenConfig();
Path p = cli.newDir("foo", true);
Path settings = p.resolve("settings.xml");
Files.createFile(settings);
Path existingSettings = config.getSettings();
Assert.assertNull(existingSettings);
cli.execute("maven set-settings-file " + settings.toFile().getAbsolutePath());
Assert.assertEquals(settings, config.getSettings());
Assert.assertEquals(settings, Configuration.parse().getMavenConfig().getSettings());
cli.execute("maven get-info");
Assert.assertTrue(cli.getOutput().contains(settings.toFile().getAbsolutePath()));
cli.execute("maven reset-settings-file");
Assert.assertNull(config.getSettings());
Assert.assertNull(Configuration.parse().getMavenConfig().getSettings());
}
Aggregations