use of org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout in project tomee by apache.
the class AbstractTomEEMojo method resolve.
private File resolve() {
if (!settings.isOffline()) {
try {
if ("snapshots".equals(apacheRepos) || "true".equals(apacheRepos)) {
remoteRepos.add(new DefaultArtifactRepository("apache", "https://repository.apache.org/content/repositories/snapshots/", new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(true, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN), new ArtifactRepositoryPolicy(false, UPDATE_POLICY_NEVER, CHECKSUM_POLICY_WARN)));
} else {
try {
// to check it is a uri
new URI(apacheRepos);
remoteRepos.add(new DefaultArtifactRepository("additional-repo-tomee-mvn-plugin", apacheRepos, new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(true, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN), new ArtifactRepositoryPolicy(true, UPDATE_POLICY_NEVER, CHECKSUM_POLICY_WARN)));
} catch (final URISyntaxException e) {
// ignored, use classical repos
}
}
} catch (final UnsupportedOperationException uoe) {
// can happen if remoterepos is unmodifiable (possible in complex builds)
// no-op
}
} else if (remoteRepos != null && remoteRepos.isEmpty()) {
remoteRepos = new ArrayList<ArtifactRepository>();
}
if ((tomeeClassifier != null && (tomeeClassifier.isEmpty() || tomeeClassifier.equals("ignore"))) || ("org.apache.tomee".equals(tomeeGroupId) && "openejb-standalone".equals(tomeeArtifactId))) {
tomeeClassifier = null;
}
try {
final Artifact artifact = factory.createDependencyArtifact(tomeeGroupId, tomeeArtifactId, createFromVersion(tomeeVersion), tomeeType, tomeeClassifier, SCOPE_COMPILE);
resolver.resolve(artifact, remoteRepos, local);
return artifact.getFile();
} catch (final Exception e) {
getLog().error(e.getMessage(), e);
throw new TomEEException(e.getMessage(), e);
}
}
use of org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout 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;
}
use of org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout in project cuke4duke by cucumber.
the class CucumberMojoTest method setUp.
@Before
public void setUp() {
mojo = new CucumberMojo();
mojo.launchDirectory = new File(".");
mojo.mavenProject = new MavenProject();
mojo.mavenProject.setFile(new File("../."));
mojo.compileClasspathElements = new ArrayList<String>();
mojo.pluginArtifacts = new ArrayList<Artifact>();
mojo.testClasspathElements = new ArrayList<String>();
mojo.localRepository = new DefaultArtifactRepository("", "", new DefaultRepositoryLayout());
}
Aggregations