List of usage examples for org.apache.maven MavenExecutionException MavenExecutionException
public MavenExecutionException(String message, Throwable cause)
From source file:org.eclipse.tycho.core.maven.utils.PluginRealmHelper.java
License:Open Source License
private static MavenExecutionException newMavenExecutionException(Exception cause) { return new MavenExecutionException("Could not setup plugin ClassRealm", cause); }
From source file:org.eclipse.tycho.osgi.runtime.DefaultTychoP2RuntimeResolver.java
License:Open Source License
public List<File> getRuntimeLocations(MavenSession session) throws MavenExecutionException { MavenSession oldSession = sessionContext.getSession(); sessionContext.setSession(session);/*from w w w. jav a2s. com*/ try { return location.getRuntimeLocations(); } catch (MavenExecutionException e) { throw e; } catch (Exception e) { throw new MavenExecutionException("Could not resolve Tycho P2 runtime", e); } finally { sessionContext.setSession(oldSession); } }
From source file:org.eclipse.tycho.osgi.runtime.TychoOsgiRuntimeLocator.java
License:Open Source License
private void addRuntimeArtifact(EquinoxRuntimeDescription description, MavenSession session, Dependency dependency) throws MavenExecutionException { Artifact artifact = resolveDependency(session, dependency); if ("zip".equals(dependency.getType())) { File artifactFile = new File(session.getLocalRepository().getBasedir(), session.getLocalRepository().pathOf(artifact)); File eclipseDir = new File(artifactFile.getParentFile(), "eclipse"); FileLocker locker = fileLockService.getFileLocker(artifactFile); locker.lock();//from w w w . j a va 2 s .c o m try { if (!eclipseDir.exists() || artifact.isSnapshot()) { logger.debug("Extracting Tycho's OSGi runtime"); if (artifact.getFile().lastModified() > eclipseDir.lastModified()) { logger.debug("Unpacking Tycho's OSGi runtime to " + eclipseDir); try { FileUtils.deleteDirectory(eclipseDir); } catch (IOException e) { logger.warn( "Failed to delete Tycho's OSGi runtime " + eclipseDir + ": " + e.getMessage()); } unArchiver.setSourceFile(artifact.getFile()); unArchiver.setDestDirectory(eclipseDir.getParentFile()); try { unArchiver.extract(); } catch (ArchiverException e) { throw new MavenExecutionException( "Failed to unpack Tycho's OSGi runtime: " + e.getMessage(), e); } eclipseDir.setLastModified(artifact.getFile().lastModified()); } } } finally { locker.release(); } description.addInstallation(eclipseDir); } else { description.addBundle(artifact.getFile()); } }
From source file:org.eclipse.tycho.osgi.runtime.TychoOsgiRuntimeLocator.java
License:Open Source License
public Artifact resolveDependency(MavenSession session, Dependency dependency) throws MavenExecutionException { Artifact artifact = repositorySystem.createArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getType()); ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setArtifact(artifact);/*from w ww. j av a2 s . c o m*/ request.setResolveRoot(true).setResolveTransitively(false); request.setLocalRepository(session.getLocalRepository()); request.setRemoteRepositories(getPluginRepositories(session)); request.setCache(session.getRepositoryCache()); request.setOffline(session.isOffline()); request.setProxies(session.getSettings().getProxies()); request.setForceUpdate(session.getRequest().isUpdateSnapshots()); ArtifactResolutionResult result = repositorySystem.resolve(request); try { resolutionErrorHandler.throwErrors(request, result); } catch (ArtifactResolutionException e) { throw new MavenExecutionException("Could not resolve artifact for Tycho's OSGi runtime", e); } return artifact; }
From source file:org.eclipse.tycho.osgi.runtime.TychoP2RuntimeLocator.java
License:Open Source License
private File resolveRuntimeArtifact(MavenSession session, Dependency d) throws MavenExecutionException { Artifact artifact = repositorySystem.createArtifact(d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getType());// www .j av a 2s. co m if ("zip".equals(d.getType())) { File artifactFile = new File(session.getLocalRepository().getBasedir(), session.getLocalRepository().pathOf(artifact)); File eclipseDir = new File(artifactFile.getParentFile(), "eclipse"); FileLocker locker = fileLockService.getFileLocker(artifactFile); locker.lock(); try { if (eclipseDir.exists() && !artifact.isSnapshot()) { return eclipseDir; } logger.debug("Resolving P2 runtime"); resolveArtifact(session, artifact); if (artifact.getFile().lastModified() > eclipseDir.lastModified()) { logger.debug("Unpacking P2 runtime to " + eclipseDir); try { FileUtils.deleteDirectory(eclipseDir); } catch (IOException e) { logger.warn("Failed to delete P2 runtime " + eclipseDir + ": " + e.getMessage()); } unArchiver.setSourceFile(artifact.getFile()); unArchiver.setDestDirectory(eclipseDir.getParentFile()); try { unArchiver.extract(); } catch (ArchiverException e) { throw new MavenExecutionException("Failed to unpack P2 runtime: " + e.getMessage(), e); } eclipseDir.setLastModified(artifact.getFile().lastModified()); } } finally { locker.release(); } return eclipseDir; } else { return resolveArtifact(session, artifact); } }
From source file:org.eclipse.tycho.osgi.runtime.TychoP2RuntimeLocator.java
License:Open Source License
private File resolveArtifact(MavenSession session, Artifact artifact) throws MavenExecutionException { List<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>(); for (MavenProject project : session.getProjects()) { repositories.addAll(project.getPluginArtifactRepositories()); }//from ww w . ja v a2s .co m repositories = repositorySystem.getEffectiveRepositories(repositories); ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setArtifact(artifact); request.setResolveRoot(true).setResolveTransitively(false); request.setLocalRepository(session.getLocalRepository()); request.setRemoteRepositories(repositories); request.setCache(session.getRepositoryCache()); request.setOffline(session.isOffline()); request.setForceUpdate(session.getRequest().isUpdateSnapshots()); ArtifactResolutionResult result = repositorySystem.resolve(request); try { resolutionErrorHandler.throwErrors(request, result); } catch (ArtifactResolutionException e) { throw new MavenExecutionException("Could not resolve tycho-p2-runtime", e); } return artifact.getFile(); }
From source file:org.eclipse.tycho.osgi.runtime.WorkspaceTychoOsgiRuntimeLocator.java
License:Open Source License
public boolean addProduct(EquinoxRuntimeDescription result, Artifact pom) throws MavenExecutionException { ProductConfiguration product;/*from ww w.j ava2 s . c om*/ try { product = ProductConfiguration .read(new File(pom.getFile().getParentFile(), pom.getArtifactId() + ".product")); } catch (IOException e) { return false; } // the above fails with IOException if .product file is not available or can't be read // we get here only when we have valid product instance Set<String> missing = new LinkedHashSet<String>(); for (PluginRef pluginRef : product.getPlugins()) { DevBundleInfo bundleInfo = workspaceState.getBundleInfo(pluginRef.getId(), pluginRef.getVersion()); if (bundleInfo != null) { addBundle(result, bundleInfo); } else { missing.add(pluginRef.toString()); } } if (!missing.isEmpty()) { throw new MavenExecutionException( "Inconsistent m2e-tycho workspace state, missing bundles: " + missing.toString(), (Throwable) null); } Map<String, BundleConfiguration> bundleConfigurations = product.getPluginConfiguration(); if (bundleConfigurations != null) { for (BundleConfiguration bundleConfiguration : bundleConfigurations.values()) { result.addBundleStartLevel(bundleConfiguration.getId(), bundleConfiguration.getStartLevel(), bundleConfiguration.isAutoStart()); } } return true; }
From source file:org.eclipse.tycho.osgi.runtime.WorkspaceTychoOsgiRuntimeLocator.java
License:Open Source License
public void addPlatformProperties(EquinoxRuntimeDescription result) throws MavenExecutionException { result.addPlatformProperty("osgi.install.area", stateLocation.getAbsolutePath()); File devproperties = new File(stateLocation, "dev.properties"); try {//from w w w. j ava2 s .c o m OutputStream os = new BufferedOutputStream(new FileOutputStream(devproperties)); try { deventries.store(os, null); } finally { IOUtil.close(os); } result.addPlatformProperty("osgi.dev", devproperties.toURI().toURL().toExternalForm()); } catch (IOException e) { throw new MavenExecutionException("Could not write dev.properties", e); } }
From source file:org.eclipse.tycho.p2.facade.internal.TychoP2RuntimeLocator.java
License:Open Source License
private File resolveRuntimeArtifact(MavenSession session, Dependency d) throws MavenExecutionException { Artifact artifact = repositorySystem.createArtifact(d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getType());// w w w . ja v a2 s. co m if ("zip".equals(d.getType())) { File p2Directory = new File(session.getLocalRepository().getBasedir(), session.getLocalRepository().pathOf(artifact)); p2Directory = new File(p2Directory.getParentFile(), "eclipse"); if (p2Directory.exists() && !artifact.isSnapshot()) { return p2Directory; } logger.debug("Resolving P2 runtime"); resolveArtifact(session, artifact); if (artifact.getFile().lastModified() > p2Directory.lastModified()) { logger.debug("Unpacking P2 runtime to " + p2Directory); try { FileUtils.deleteDirectory(p2Directory); } catch (IOException e) { logger.warn("Failed to delete P2 runtime " + p2Directory + ": " + e.getMessage()); } unArchiver.setSourceFile(artifact.getFile()); unArchiver.setDestDirectory(p2Directory.getParentFile()); try { unArchiver.extract(); } catch (ArchiverException e) { throw new MavenExecutionException("Failed to unpack P2 runtime: " + e.getMessage(), e); } p2Directory.setLastModified(artifact.getFile().lastModified()); } return p2Directory; } else { return resolveArtifact(session, artifact); } }
From source file:org.jboss.maven.extension.dependency.modelmodifier.versionoverride.DepVersionOverrider.java
License:Apache License
/** * Get dependency management version properties from a remote POM * * @return Map between the GA of the dependency and the version of the dependency. If the property is not set, * returns an empty map/*from w w w .j a v a 2 s . c o m*/ */ private static Map<String, String> loadRemoteDepVersionOverrides() throws MavenExecutionException { Properties systemProperties = System.getProperties(); String depMgmtPomCSV = systemProperties.getProperty(DEPENDENCY_MANAGEMENT_POM_PROPERTY); Map<String, String> versionOverrides = new HashMap<String, String>(0); if (depMgmtPomCSV == null) { return versionOverrides; } String[] depMgmtPomGAVs = depMgmtPomCSV.split(","); // Iterate in reverse order so that the first GAV in the list overwrites the last for (int i = (depMgmtPomGAVs.length - 1); i > -1; --i) { String nextGAV = depMgmtPomGAVs[i]; if (!MavenUtil.validGav(nextGAV)) { Log.getLog().warn("Skipping invalid dependency management GAV: " + nextGAV); continue; } try { EffectiveModelBuilder resolver = EffectiveModelBuilder.getInstance(); versionOverrides.putAll(resolver.getRemoteDependencyVersionOverrides(nextGAV)); } catch (ArtifactResolutionException e) { Log.getLog().error("Unable to resolve remote pom: " + e); throw new MavenExecutionException("Unable to resolve remote pom", e); } catch (ArtifactDescriptorException e) { Log.getLog().error("Unable to resolve remote pom: " + e); throw new MavenExecutionException("Unable to resolve remote pom", e); } catch (ModelBuildingException e) { Log.getLog().error("Unable to resolve remote pom: " + e); throw new MavenExecutionException("Unable to resolve remote pom", e); } } return versionOverrides; }