List of usage examples for org.apache.maven MavenExecutionException MavenExecutionException
public MavenExecutionException(String message, Throwable cause)
From source file:ch.rotscher.mavenext.VersionOverrideModelReader.java
License:Apache License
@Override public Model read(InputStream input, Map<String, ?> options) throws IOException { Model model = super.read(input, options); // this property is set from the command line with -Dversion.override String version = System.getProperty(MAVENEXT_RELEASE_VERSION); if (version == null) { return model; }/*from w ww. j av a 2s. com*/ String currentGroupId = getGroupId(model); if (rootPomData == null) { rootPomData = new RootPomData(model, version, logger); } version = rootPomData.version; Boolean beStrict = Boolean.parseBoolean(System.getProperty(MAVENEXT_BE_STRICT)); //the version is overridden here: ch.rotscher.app and ch.rotscher.app.domain // vs. not overridden in that case: ch.rotscher.app and ch.rotscher.application if (currentGroupId.equals(rootPomData.groupId) || currentGroupId.startsWith(rootPomData.groupId + ".")) { String modelVersion = getVersion(model); if (beStrict && !modelVersion.equals(rootPomData.originalVersion)) { if (logger.isDebugEnabled()) { logger.debug(String.format("version of %s (%s) not changed as it differ: %s", model, model.getVersion(), rootPomData.version)); } } else { model.setVersion(version); if (logger.isDebugEnabled()) { logger.debug(String.format("changing version of %s to %s", model, version)); } Parent parent = model.getParent(); if (parent != null && (parent.getGroupId().equals(rootPomData.groupId) || parent.getGroupId().startsWith(rootPomData.groupId + "."))) { logger.debug(String.format("changing version of parent %s to %s", parent, version)); parent.setVersion(version); } } } Boolean checkSnapshotDependencies = Boolean.parseBoolean(System.getProperty(MAVENEXT_CHECK_SNAPSHOT_DEP)); Boolean failOnError = Boolean.parseBoolean(System.getProperty(MAVENEXT_CHECK_SNAPSHOT_DEP_FAIL_ON_ERROR)); if (checkSnapshotDependencies == Boolean.TRUE) { for (Dependency dep : model.getDependencies()) { String depVersion = dep.getVersion(); if (depVersion != null && depVersion.contains("SNAPSHOT")) { File pomFile = model.getPomFile(); String pomFilePath = "[path not available]"; if (pomFile != null) { pomFilePath = pomFile.getPath(); } String errorMsg = String.format("there is a snapshot dependency (%s) in %s (%s)", dep, model, pomFilePath); if (failOnError == Boolean.TRUE) { logger.warn(errorMsg); // wrap in a IOException as this one is thrown in the signature throw new IOException(new MavenExecutionException(errorMsg, model.getPomFile())); } else { logger.warn(errorMsg); } } } } return model; }
From source file:com.basistech.mext.VersionGeneratorLifecycleParticipant.java
License:Open Source License
@Override public void afterSessionStart(MavenSession session) throws MavenExecutionException { File projectBase = new File(session.getRequest().getBaseDirectory()); File policyFile = new File(projectBase, "version-policy.txt"); if (policyFile.exists()) { String template;/*from w ww . j av a 2 s .co m*/ try { template = fileContents(policyFile); } catch (IOException e) { throw new MavenExecutionException("Failed to read " + policyFile.getAbsolutePath(), e); } String[] bits = template.split("="); String prop = bits[0]; String valueTemplate = bits[1]; SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); String timestamp = format.format(new Date()); String rev = valueTemplate.replace("${timestamp}", timestamp); LOG.info("Setting {} to {}", prop, rev); session.getUserProperties().put(prop, rev); } }
From source file:com.doublefx.maven.utils.flexmojos.mavenValidator.FlexMojosExtensionInstallationHelper.java
License:Apache License
private static MavenExecutionException newMavenExecutionException(Exception cause) { return new MavenExecutionException(cause.getMessage(), cause); }
From source file:com.github.htfv.maven.plugins.buildconfigurator.extension.BuildConfiguratorExtension.java
License:Apache License
/** * Configures loaded projects.//from ww w . j ava2 s . co m * * @param session * session containing loaded projects. * * @throws MavenExecutionException * if projects could not be counfigured. */ @Override public void afterProjectsRead(final MavenSession session) throws MavenExecutionException { try { for (final MavenProject project : session.getProjects()) { // // Check to see if Build Configurator is configured for this project. // final Plugin plugin = getPlugin(project); if (plugin == null) { continue; } // // Configure the project. // final ConfigureRequest request = new ConfigureRequest.Builder() .extensionConfiguration(getModel(plugin)).project(project).build(); buildConfigurator.configure(request); } } catch (final Exception e) { throw new MavenExecutionException(e.getMessage(), e); } }
From source file:com.github.shyiko.sme.ServersExtension.java
License:Apache License
@Override public void afterProjectsRead(MavenSession session) throws MavenExecutionException { MojoExecution mojoExecution = new MojoExecution(new MojoDescriptor()); ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, mojoExecution); Properties userProperties = session.getUserProperties(); boolean exportAsSysProp = isExtensionProperty(session, "servers.exportAsSysProp"); Map<String, String> properties = new HashMap<String, String>(); try {//from w ww. j a v a 2 s. c o m for (Server server : session.getSettings().getServers()) { String serverId = server.getId(); for (String field : FIELDS) { String[] aliases = getAliases(serverId, field); String fieldNameWithFirstLetterCapitalized = upperCaseFirstLetter(field); String fieldValue = (String) Server.class.getMethod("get" + fieldNameWithFirstLetterCapitalized) .invoke(server); if (fieldValue != null) { fieldValue = decryptInlinePasswords(fieldValue); } for (String alias : aliases) { String userPropertyValue = userProperties.getProperty(alias); if (userPropertyValue != null) { fieldValue = userPropertyValue; break; } } String resolvedValue = (String) expressionEvaluator.evaluate(fieldValue); Server.class .getMethod("set" + fieldNameWithFirstLetterCapitalized, new Class[] { String.class }) .invoke(server, resolvedValue); if (resolvedValue != null) { for (String alias : aliases) { properties.put(alias, resolvedValue); } } } } if (exportAsSysProp) { System.getProperties().putAll(properties); } else { for (MavenProject project : session.getProjects()) { Properties projectProperties = project.getProperties(); projectProperties.putAll(properties); } } } catch (Exception e) { throw new MavenExecutionException("Failed to expose settings.servers.*", e); } }
From source file:com.jayway.maven.plugins.android.phase_prebuild.AarMavenLifecycleParticipant.java
License:Open Source License
private Collection<Artifact> getProjectsArtifacts(MavenSession session, MavenProject project) throws MavenExecutionException { final DependencyResolver resolver = new DependencyResolver(log, repoSystem, session.getRepositorySession(), project.getRemoteProjectRepositories(), artifactHandler); try {/*ww w .j av a 2s . c o m*/ return resolver.getDependenciesFor(project.getArtifact()); } catch (MojoExecutionException e) { throw new MavenExecutionException("Could not resolve dependencies for " + project.getArtifact(), e); } }
From source file:com.jayway.maven.plugins.android.phase_prebuild.AarMavenLifecycleParticipant.java
License:Open Source License
/** * Add the dependent library classes to the project classpath. *///from ww w. j a va2 s . c o m private void addClassesToClasspath(BuildHelper helper, MavenProject project, Artifact artifact) throws MavenExecutionException { // Work out where the dep will be extracted and calculate the file path to the classes jar. log.debug("Adding to classpath : " + artifact); // This is location where the GenerateSourcesMojo will extract the classes. final File classesJar = helper.getUnpackedClassesJar(artifact); log.info(" : " + classesJar); // In order to satisfy the LifecycleDependencyResolver on execution up to a phase that // has a Mojo requiring dependency resolution I need to create a dummy classesJar here. classesJar.getParentFile().mkdirs(); try { classesJar.createNewFile(); log.debug("Created dummy " + classesJar.getName() + " exist=" + classesJar.exists()); } catch (IOException e) { throw new MavenExecutionException("Could not add " + classesJar.getName() + " as dependency", e); } // Add the classes to the classpath final Dependency dependency = createSystemScopeDependency(artifact, classesJar); project.getModel().addDependency(dependency); }
From source file:com.jayway.maven.plugins.android.phase_prebuild.ClasspathModifierLifecycleParticipant.java
License:Open Source License
/** * Add the dependent library classes to the project classpath. *///from w ww.j ava2 s. co m private void addClassesToClasspath(UnpackedLibHelper helper, MavenProject project, Artifact artifact) throws MavenExecutionException { // Work out where the dep will be extracted and calculate the file path to the classes jar. // This is location where the GenerateSourcesMojo will extract the classes. final File classesJar = helper.getUnpackedClassesJar(artifact); log.debug("Adding to classpath : " + classesJar); // In order to satisfy the LifecycleDependencyResolver on execution up to a phase that // has a Mojo requiring dependency resolution I need to create a dummy classesJar here. classesJar.getParentFile().mkdirs(); try { classesJar.createNewFile(); log.debug("Created dummy " + classesJar.getName() + " exist=" + classesJar.exists()); } catch (IOException e) { throw new MavenExecutionException("Could not add " + classesJar.getName() + " as dependency", e); } // Add the classes to the classpath final Dependency dependency = createSystemScopeDependency(artifact, classesJar, null); project.getModel().addDependency(dependency); }
From source file:com.rebaze.maven.focus.FocusConfigurationProcessor.java
License:Open Source License
private Repository findRepository(MavenExecutionRequest request, String repoID) throws MavenExecutionException { for (Profile profile : request.getProfiles()) { for (Repository repo : profile.getRepositories()) { if (repo.getId().equals(repoID)) { return repo; }//from ww w . j a va2 s. co m } } throw new MavenExecutionException("Focus repository " + repoID + " is not configured.", request.getPom()); }
From source file:com.rebaze.maven.payload.PayloadEventSpy.java
License:Open Source License
@Override public void onEvent(Object event) throws Exception { super.onEvent(event); try {//from ww w.j ava 2 s. com if (event instanceof ExecutionEvent) { org.apache.maven.execution.ExecutionEvent exec = (ExecutionEvent) event; if (exec.getProject() != null && exec.getProject().isExecutionRoot()) { if (m_reactorProject == null) { m_eventLog = new ArrayList<>(); m_reactorProject = exec.getProject(); } } } else if (event instanceof org.eclipse.aether.RepositoryEvent) { m_eventLog.add((RepositoryEvent) event); } } catch (Exception e) { throw new MavenExecutionException("Problem!", e); } }