use of org.apache.maven.settings.io.xpp3.SettingsXpp3Reader in project indy by Commonjava.
the class SettingsGeneratedForRemoteRepoTest method generateSettingsXml.
@Test
public void generateSettingsXml() throws Exception {
final IndyClientHttp http = getHttp();
// all mavdav requests are siblings of the default base-url suffix '/api/'
final String url = getDotMavenUrl("settings/remote/settings-central.xml");
System.out.println("Requesting: " + url);
final HttpResources resources = http.getRaw(new HttpGet(url));
InputStream stream = null;
Settings settings = null;
try {
stream = resources.getResponseStream();
settings = new SettingsXpp3Reader().read(stream);
} finally {
closeQuietly(stream);
closeQuietly(resources);
}
assertThat(settings.getLocalRepository(), equalTo("${user.home}/.m2/repo-remote-central"));
assertThat(settings.getMirrors(), notNullValue());
assertThat(settings.getMirrors().size(), equalTo(1));
final Mirror mirror = settings.getMirrors().get(0);
assertThat(mirror.getUrl(), equalTo(http.toIndyUrl("remote/central")));
}
use of org.apache.maven.settings.io.xpp3.SettingsXpp3Reader in project tomee by apache.
the class TomEEMavenPluginRule method defaults.
protected static <T extends AbstractTomEEMojo> T defaults(final T tomEEMojo) {
// settings
final File settingsXml = new File(System.getProperty("user.home") + "/.m2/settings.xml");
if (settingsXml.exists()) {
try {
final FileReader reader = new FileReader(settingsXml);
try {
tomEEMojo.settings = new SettingsXpp3Reader().read(reader, false);
} finally {
reader.close();
}
} catch (final Exception e) {
// no-op
}
}
tomEEMojo.project = new MavenProject() {
@Override
public Set getArtifacts() {
return Collections.emptySet();
}
};
if (tomEEMojo.settings == null) {
tomEEMojo.settings = new Settings();
}
tomEEMojo.settings.setOffline(true);
if (tomEEMojo.settings.getLocalRepository() == null || "".equals(tomEEMojo.settings.getLocalRepository())) {
tomEEMojo.settings.setLocalRepository(System.getProperty("openejb.m2.home", System.getProperty("user.home") + "/.m2/repository"));
}
// we don't deploy anything by default
tomEEMojo.skipCurrentProject = true;
// our well known web profile ;)
tomEEMojo.tomeeGroupId = "org.apache.tomee";
tomEEMojo.tomeeArtifactId = "apache-tomee";
tomEEMojo.tomeeVersion = OpenEjbVersion.get().getVersion();
tomEEMojo.tomeeClassifier = "webprofile";
tomEEMojo.tomeeType = "zip";
// target config
tomEEMojo.catalinaBase = new File("target/mvn-test");
Files.mkdirs(tomEEMojo.catalinaBase);
// some defaults
tomEEMojo.simpleLog = true;
tomEEMojo.quickSession = true;
tomEEMojo.libDir = "lib";
tomEEMojo.webappDir = "webapps";
tomEEMojo.appDir = "apps";
tomEEMojo.bin = new File(tomEEMojo.catalinaBase.getPath() + "-bin");
tomEEMojo.config = new File(tomEEMojo.catalinaBase.getPath() + "-conf");
tomEEMojo.lib = new File(tomEEMojo.catalinaBase.getPath() + "-lib");
tomEEMojo.tomeeHttpPort = Integer.toString(NetworkUtil.getNextAvailablePort());
tomEEMojo.tomeeAjpPort = Integer.toString(NetworkUtil.getNextAvailablePort());
tomEEMojo.tomeeShutdownPort = Integer.toString(NetworkUtil.getNextAvailablePort());
tomEEMojo.tomeeShutdownCommand = "SHUTDOWN";
tomEEMojo.tomeeHost = "localhost";
tomEEMojo.useConsole = true;
tomEEMojo.checkStarted = true;
tomEEMojo.overrideOnUnzip = true;
tomEEMojo.skipRootFolderOnUnzip = true;
// we mock all the artifact resolution in test
tomEEMojo.remoteRepos = new LinkedList<ArtifactRepository>();
tomEEMojo.local = new DefaultArtifactRepository("local", tomEEMojo.settings.getLocalRepository(), new DefaultRepositoryLayout());
tomEEMojo.factory = ArtifactFactory.class.cast(Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[] { ArtifactFactory.class }, new InvocationHandler() {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
return new DefaultArtifact(String.class.cast(args[0]), String.class.cast(args[1]), VersionRange.class.cast(args[2]), String.class.cast(args[5]), String.class.cast(args[3]), args[4] == null ? "" : String.class.cast(args[4]), null) {
@Override
public File getFile() {
return new File(tomEEMojo.settings.getLocalRepository(), getGroupId().replace('.', '/') + '/' + getArtifactId().replace('.', '/') + '/' + getVersion() + '/' + getArtifactId().replace('.', '/') + '-' + getVersion() + (args[4] == null ? "" : '-' + getClassifier()) + '.' + getType());
}
};
}
}));
tomEEMojo.resolver = ArtifactResolver.class.cast(Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[] { ArtifactResolver.class }, new InvocationHandler() {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
return null;
}
}));
return tomEEMojo;
}
Aggregations