org.apache.maven.plugin.MojoFailureException Java Examples

The following examples show how to use org.apache.maven.plugin.MojoFailureException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlattenMojo.java    From flatten-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void execute()
    throws MojoExecutionException, MojoFailureException
{

    getLog().info( "Generating flattened POM of project " + this.project.getId() + "..." );

    File originalPomFile = this.project.getFile();
    Model flattenedPom = createFlattenedPom( originalPomFile );
    String headerComment = extractHeaderComment( originalPomFile );

    File flattenedPomFile = getFlattenedPomFile();
    writePom( flattenedPom, flattenedPomFile, headerComment );

    if ( isUpdatePomFile() )
    {
        this.project.setPomFile( flattenedPomFile );
    }
}
 
Example #2
Source File: CommandExecutor.java    From wildfly-maven-plugin with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Executes CLI commands based on the configuration.
 *
 * @param config the configuration used to execute the CLI commands
 *
 * @throws MojoFailureException   if the JBoss Home directory is required and invalid
 * @throws MojoExecutionException if an error occurs executing the CLI commands
 */
public void execute(final CommandConfiguration config) throws MojoFailureException, MojoExecutionException {
    if (config.isOffline()) {
        // The jbossHome is required for offline CLI
        if (!ServerHelper.isValidHomeDirectory(config.getJBossHome())) {
            throw new MojoFailureException("Invalid JBoss Home directory is not valid: " + config.getJBossHome());
        }
        executeInNewProcess(config);
    } else {
        if (config.isFork()) {
            executeInNewProcess(config);
        } else {
            executeInProcess(config);
        }
    }
}
 
Example #3
Source File: TestInstrumentMojo.java    From coroutines with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();

    File testOutputFolder = new File(getProject().getBuild().getTestOutputDirectory());
    if (!testOutputFolder.isDirectory()) {
        log.warn("Test folder doesn't exist -- nothing to instrument");
        return;
    }
    
    List<String> classpath;
    try {
        classpath = getProject().getTestClasspathElements();
    } catch (DependencyResolutionRequiredException ex) {
        throw new MojoExecutionException("Dependency resolution problem", ex);
    }
    
    log.debug("Processing test output folder ... ");
    instrumentPath(log, classpath, testOutputFolder);
}
 
Example #4
Source File: GenRepoInfoFileMojo.java    From app-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
  if (skip) {
    getLog().info("Skipping appengine:genRepoInfoFile");
    return;
  }
  try {
    getAppEngineFactory()
        .genRepoInfoFile()
        .generate(
            GenRepoInfoFileConfiguration.builder()
                .outputDirectory(outputDirectory == null ? null : outputDirectory.toPath())
                .sourceDirectory(sourceDirectory == null ? null : sourceDirectory.toPath())
                .build());
  } catch (AppEngineException aee) {
    if (!ignoreErrors) {
      throw new MojoExecutionException(HOW_TO_FIX_MSG, aee);
    } else {
      logger.warning(HOW_TO_FIX_MSG);
    }
  }
}
 
Example #5
Source File: PropertyResolverTest.java    From properties-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void unknownPlaceholderIsLeftAsIs()
    throws MojoFailureException
{
    Properties properties = new Properties();
    properties.setProperty( "p1", "${p2}" );
    properties.setProperty( "p2", "value" );
    properties.setProperty( "p3", "${unknown}" );

    String value1 = resolver.getPropertyValue( "p1", properties, new Properties() );
    String value2 = resolver.getPropertyValue( "p2", properties, new Properties() );
    String value3 = resolver.getPropertyValue( "p3", properties, new Properties() );

    assertEquals( "value", value1 );
    assertEquals( "value", value2 );
    assertEquals( "${unknown}", value3 );
}
 
Example #6
Source File: AnalyzeMojo.java    From wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().info("Analyzing for " + this.gav);

    this.dir = Paths.get(this.projectBuildDir, "wildfly-swarm-archive");
    this.modulesDir = this.dir.resolve("modules");

    try {
        walkModulesDir();
        walkDependencies();
    } catch (IOException e) {
        throw new MojoFailureException("Unable to inspect modules/ dir", e);
    }

    Graph.Artifact artifact = this.graph.getClosestArtifact(this.gav);
    if (artifact == null) {
        throw new MojoFailureException("Unable to find artifact: " + this.gav);
    }

    DumpGraphVisitor visitor = new DumpGraphVisitor();
    artifact.accept(visitor);

}
 
Example #7
Source File: HtmlGeneratorMojo.java    From protostuff-compiler with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    super.execute();
    ProtostuffCompiler compiler = new ProtostuffCompiler();
    final Path sourcePath = getSourcePath();
    List<String> protoFiles = findProtoFiles(sourcePath);
    ModuleConfiguration moduleConfiguration = ImmutableModuleConfiguration.builder()
            .name("html")
            .includePaths(singletonList(sourcePath))
            .generator(CompilerModule.HTML_COMPILER)
            .output(target.getAbsolutePath())
            .putOptions(HtmlGenerator.PAGES, pages)
            .addAllProtoFiles(protoFiles)
            .build();
    compiler.compile(moduleConfiguration);
}
 
Example #8
Source File: CheckPluginVersions.java    From unleash-maven-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private void failIfSnapshotsAreReferenced(Multimap<MavenProject, ArtifactCoordinates> snapshotsByProject,
    Map<MavenProject, PomPropertyResolver> propertyResolvers) throws MojoFailureException {
  if (!snapshotsByProject.values().isEmpty()) {
    this.log.error(
        "\tThere are references to SNAPSHOT plugins! The following list contains all SNAPSHOT plugins grouped by module:");

    for (MavenProject project : snapshotsByProject.keySet()) {
      PomPropertyResolver propertyResolver = propertyResolvers.get(project);
      Collection<ArtifactCoordinates> snapshots = snapshotsByProject.get(project);
      if (!snapshots.isEmpty()) {
        this.log.error("\t\t[PROJECT] " + ProjectToString.INSTANCE.apply(project));

        for (ArtifactCoordinates plugin : snapshots) {
          String resolvedVersion = propertyResolver.expandPropertyReferences(plugin.getVersion());
          String coordinates = plugin.toString();
          if (!Objects.equal(resolvedVersion, plugin.getVersion())) {
            coordinates = coordinates + " (resolves to " + resolvedVersion + ")";
          }
          this.log.error("\t\t\t[PLUGIN] " + coordinates);
        }
      }
    }
    throw new MojoFailureException("The project cannot be released due to one or more SNAPSHOT plugins!");
  }
}
 
Example #9
Source File: CamelKafkaConnectorCreateMojo.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
@Override
public void executeAll() throws MojoFailureException {
    if (name == null || name.isEmpty()) {
        throw new MojoFailureException("Connector name must be specified as the parameter");
    }
    if (name.startsWith("camel-")) {
        name = name.substring("camel-".length());
    }
    if (name.endsWith(KAFKA_CONNECTORS_SUFFIX)) {
        name = name.substring(0, name.length() - KAFKA_CONNECTORS_SUFFIX.length());
    }
    try {
        createConnector();
    } catch (Exception e) {
        throw new MojoFailureException("Fail to create connector " + name, e);
    }
}
 
Example #10
Source File: Stop.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void execute() throws MojoExecutionException, MojoFailureException
{
   if (getHome() == null)
      throw new MojoFailureException("Home isn't set");

   try 
   {
      ProcessController pc = ProcessController.getInstance();
      int exitCode = pc.stop(getHome());

      if (exitCode != 0)
         throw new MojoFailureException("IronJacamar instance exit code: " + exitCode);

      getLog().info("Stopped IronJacamar instance from: " + getHome());
   }
   catch (Throwable t) 
   {
      throw new MojoFailureException(t.getMessage(), t);
   }
}
 
Example #11
Source File: GitFlowReleaseStartMojo.java    From gitflow-maven-plugin with Apache License 2.0 6 votes vote down vote up
private String getNextSnapshotVersion(String currentVersion) throws MojoFailureException, VersionParseException {
    // get next snapshot version
    final String nextSnapshotVersion;
    if (!settings.isInteractiveMode()
            && StringUtils.isNotBlank(developmentVersion)) {
        nextSnapshotVersion = developmentVersion;
    } else {
        GitFlowVersionInfo versionInfo = new GitFlowVersionInfo(
                currentVersion);
        if (digitsOnlyDevVersion) {
            versionInfo = versionInfo.digitsVersionInfo();
        }

        nextSnapshotVersion = versionInfo
                .nextSnapshotVersion(versionDigitToIncrement);
    }

    if (StringUtils.isBlank(nextSnapshotVersion)) {
        throw new MojoFailureException(
                "Next snapshot version is blank.");
    }
    return nextSnapshotVersion;
}
 
Example #12
Source File: RunJarMojo.java    From kumuluzee with MIT License 6 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    repackage();

    executeMojo(
            plugin(
                    groupId("org.codehaus.mojo"),
                    artifactId("exec-maven-plugin"),
                    version("1.6.0")
            ),
            goal("exec"),
            configuration(
                    element("executable", "java"),
                    element(name("arguments"),
                            element(name("argument"), "-jar"),
                            element(name("argument"), outputDirectory + "/" + finalName + ".jar")
                    )
            ),
            executionEnvironment(project, session, buildPluginManager)
    );
}
 
Example #13
Source File: CSSMinifierMojoTest.java    From wisdom with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomArguments() throws MojoFailureException, MojoExecutionException, IOException {
    cleanup();
    less.execute();
    mojo.cleanCssArguments = "--debug -c ie7 -b";
    mojo.execute();

    File site = new File(FAKE_PROJECT_TARGET, "classes/assets/css/site-min.css");
    assertThat(site).isFile();
    assertThat(FileUtils.readFileToString(site))
            .contains("h1{color:red}");

    File style = new File(FAKE_PROJECT_TARGET, "classes/assets/less/style-min.css");
    assertThat(style).isFile();
    assertThat(FileUtils.readLines(style)).hasSize(2); // We don't remove line break.

}
 
Example #14
Source File: JApiCmpMojo.java    From japicmp with Apache License 2.0 6 votes vote down vote up
private void filterVersionPattern(List<ArtifactVersion> availableVersions, PluginParameters pluginParameters) throws MojoFailureException {
	if (pluginParameters.getParameterParam() != null && pluginParameters.getParameterParam().getOldVersionPattern() != null) {
		String versionPattern = pluginParameters.getParameterParam().getOldVersionPattern();
		Pattern pattern;
		try {
			pattern = Pattern.compile(versionPattern);
		} catch (PatternSyntaxException e) {
			throw new MojoFailureException("Could not compile provided versionPattern '" + versionPattern + "' as regular expression: " + e.getMessage(), e);
		}
		for (Iterator<ArtifactVersion> versionIterator = availableVersions.iterator(); versionIterator.hasNext(); ) {
			ArtifactVersion version = versionIterator.next();
			Matcher matcher = pattern.matcher(version.toString());
			if (!matcher.matches()) {
				versionIterator.remove();
				if (getLog().isDebugEnabled()) {
					getLog().debug("Filtering version '" + version.toString() + "' because it does not match configured versionPattern '" + versionPattern + "'.");
				}
			}
		}
	} else {
		getLog().debug("Parameter <oldVersionPattern> not configured, i.e. no version filtered.");
	}
}
 
Example #15
Source File: KarmaIntegrationTestMojo.java    From wisdom with Apache License 2.0 6 votes vote down vote up
public void execute() throws MojoFailureException, MojoExecutionException {
    removeFromWatching();
    try {
        startChameleon();

        super.execute();
    } catch (IOException | BundleException e) {
        // Others exception are related to the Chameleon startup / handling
        getLog().error("Cannot start the Chameleon instance", e);
        throw new MojoExecutionException("Cannot start the Chameleon instance", e);
    } finally {
        // This property is set when launching the Chameleon instance to find the configuration. Clear it.
        System.clearProperty("application.configuration");
        stopChameleon();
    }
}
 
Example #16
Source File: An_AbstractSlf4jMojo.java    From deadcode4j with Apache License 2.0 6 votes vote down vote up
@Test
public void wrapsMavenLogger() throws MojoFailureException, MojoExecutionException {
    Log logMock = mock(Log.class);
    when(logMock.isInfoEnabled()).thenReturn(true);
    AbstractSlf4jMojo objectUnderTest = new AbstractSlf4jMojo() {
        @Override
        protected void doExecute() throws MojoExecutionException, MojoFailureException {
            LoggerFactory.getLogger(getClass()).info("Hello JUnit!");
        }
    };
    objectUnderTest.setLog(logMock);

    objectUnderTest.execute();

    verify(logMock).info("Hello JUnit!");
}
 
Example #17
Source File: RadlFromCodePlugin.java    From RADL with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
  FromJavaRadlExtractor radlFromJavaExtractor = new FromJavaRadlExtractor();
  File tempArgumentsFile = null;
  try {
    tempArgumentsFile = generateProjectArgumentsFile();
    radlFromJavaExtractor.run(
        new Arguments(new String[] { "@" + tempArgumentsFile.getAbsolutePath() }));
    getLog().info(String.format(MSG, docsDir));
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  }
  finally {
    IO.delete(tempArgumentsFile);
  }
}
 
Example #18
Source File: UnlockSnapshotsMojo.java    From versions-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * @param pom the pom to update.
 * @throws MojoExecutionException when things go wrong
 * @throws MojoFailureException when things go wrong in a very bad way
 * @throws XMLStreamException when things go wrong with XML streaming
 * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader)
 */
protected void update( ModifiedPomXMLEventReader pom )
    throws MojoExecutionException, MojoFailureException, XMLStreamException
{

    if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() )
    {
        unlockSnapshots( pom, getProject().getDependencyManagement().getDependencies() );
    }
    if ( getProject().getDependencies() != null && isProcessingDependencies() )
    {
        unlockSnapshots( pom, getProject().getDependencies() );
    }
    if ( getProject().getParent() != null && isProcessingParent() )
    {
        unlockParentSnapshot( pom, getProject().getParent() );
    }
}
 
Example #19
Source File: AbstractGitFlowMojo.java    From gitflow-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Executes git fetch and compares local branch with the remote.
 * 
 * @param branchName
 *            Branch name to fetch and compare.
 * @throws MojoFailureException
 * @throws CommandLineException
 */
protected void gitFetchRemoteAndCompare(final String branchName)
        throws MojoFailureException, CommandLineException {
    if (gitFetchRemote(branchName)) {
        getLog().info(
                "Comparing local branch '" + branchName + "' with remote '"
                        + gitFlowConfig.getOrigin() + "/" + branchName
                        + "'.");
        String revlistout = executeGitCommandReturn("rev-list",
                "--left-right", "--count", branchName + "..."
                        + gitFlowConfig.getOrigin() + "/" + branchName);

        String[] counts = org.apache.commons.lang3.StringUtils.split(
                revlistout, '\t');
        if (counts != null && counts.length > 1) {
            if (!"0".equals(org.apache.commons.lang3.StringUtils
                    .deleteWhitespace(counts[1]))) {
                throw new MojoFailureException("Remote branch '"
                        + gitFlowConfig.getOrigin() + "/" + branchName
                        + "' is ahead of the local branch '" + branchName
                        + "'. Execute git pull.");
            }
        }
    }
}
 
Example #20
Source File: AbstractScriptGeneratorMojo.java    From appassembler with MIT License 6 votes vote down vote up
protected void installDependencies( final String outputDirectory, final String repositoryName )
    throws MojoExecutionException, MojoFailureException
{
    if ( generateRepository )
    {
        // The repo where the jar files will be installed
        ArtifactRepository artifactRepository =
            artifactRepositoryFactory.createDeploymentArtifactRepository( "appassembler", "file://"
                + outputDirectory + "/" + repositoryName, getArtifactRepositoryLayout(), false );

        for ( Artifact artifact : artifacts )
        {
            installArtifact( artifact, artifactRepository, this.useTimestampInSnapshotFileName );
        }

        // install the project's artifact in the new repository
        installArtifact( projectArtifact, artifactRepository );
    }
}
 
Example #21
Source File: DdlMojoTest.java    From hibernate5-ddl-maven-plugin with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check that no Exception is thrown when a file that does not exist is
 * injected into {@link GenerateDdlMojo#persistenceXml} and then executed.
 *
 * @throws org.apache.maven.plugin.MojoExecutionException
 * @throws org.apache.maven.plugin.MojoFailureException
 * @throws java.io.IOException
 */
@Test
public void persistenceXmlDoesntExist() throws MojoExecutionException,
                                               MojoFailureException,
                                               IOException {

    mojo.setOutputDirectory(new File(TEST_DIR));

    final String[] packages = new String[]{
        "de.jpdigital.maven.plugins.hibernate5ddl.tests.entities",
        "de.jpdigital.maven.plugins.hibernate5ddl.tests.entities2"
    };
    mojo.setPackages(packages);

    final String[] dialects = new String[]{
        "mysql5"
    };
    mojo.setDialects(dialects);

    mojo.setPersistenceXml(new File("file/doesnt/exist"));

    mojo.execute();
}
 
Example #22
Source File: AbstractAsciiDocMojo.java    From helidon-build-tools with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    validateParams(inputDirectory, includes);

    // enable jruby verbose mode on debugging
    final String previousJRubyCliVerboseValue = System.getProperty(JRUBY_DEBUG_PROPERTY_NAME);
    if (getLog().isDebugEnabled()) {
        System.setProperty(JRUBY_DEBUG_PROPERTY_NAME, "true");
    }

    AtomicBoolean isPrelim = new AtomicBoolean();
    Asciidoctor asciiDoctor = createAsciiDoctor("simple", isPrelim);
    try {
        for (Path p : inputs(inputDirectory.toPath(), includes, excludes)) {
            processFile(asciiDoctor, inputDirectory.toPath(), p, isPrelim);
        }
    } catch (IOException ex) {
        throw new MojoExecutionException("Error collecting inputs", ex);
    } finally {
        if (getLog().isDebugEnabled()) {
            if (previousJRubyCliVerboseValue == null) {
                System.clearProperty(JRUBY_DEBUG_PROPERTY_NAME);
            } else {
                System.setProperty(JRUBY_DEBUG_PROPERTY_NAME, previousJRubyCliVerboseValue);
            }
        }
    }
}
 
Example #23
Source File: AbstractModuleMavenGitCodeFormatMojo.java    From git-code-format-maven-plugin with MIT License 5 votes vote down vote up
@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
  if (skip) {
    Log log = getLog();
    if (log.isInfoEnabled()) {
      log.info("skipped");
    }
    return;
  }
  if (!isEnabled()) {
    return;
  }
  doExecute();
}
 
Example #24
Source File: VulasAgentMojo.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * Has to override {@link AbstractVulasMojo#execute} as there is no dedicated {@link GoalType} for the agent preparation.
 */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
	try {
		this.prepareConfiguration();

		// >>> Changed compared to AbstractVulasMojo#execute
		final boolean do_process = this.isPassingFilter(this.project);
		if (do_process) {

			final String name = getEffectivePropertyName();
			final Properties projectProperties = this.project.getProperties();
			final String old_value = projectProperties.getProperty(name);

			VulasAgentOptions vulasAgentOptions = createVulasAgentConfig();
			final String new_value = vulasAgentOptions.prependVMArguments(old_value, getAgentJarFile());


			projectProperties.setProperty(name, new_value);
			getLog().info(name + " set to " + new_value);
		}
		// <<<
	}
	// Expected problems will be passed on as is
	catch (MojoFailureException mfe) {
		throw mfe;
	}
	// Unexpected problems (the goal execution terminates abnormally/unexpectedly)
	catch (GoalExecutionException gee) {
		throw new MojoExecutionException(gee.getMessage(), gee);
	}
	// Every other exception results in a MojoExecutionException (= unexpected)
	catch (Exception e) {
		throw new MojoExecutionException("Error during Vulas agent preparation: ", e);
	}
}
 
Example #25
Source File: JavaScriptCompilerMojoTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Test
public void testAggregatedSourceMapIsCreated() throws IOException, MojoExecutionException, MojoFailureException {
    JavaScriptCompilerMojo mojo = new JavaScriptCompilerMojo();
    mojo.googleClosureMinifierSuffix = "-min";
    mojo.basedir = new File("target/junk/root");
    mojo.buildDirectory = new File(mojo.basedir, "target");
    MavenProject project = mock(MavenProject.class);
    when(project.getArtifactId()).thenReturn("my-artifact");
    mojo.project = project;
    mojo.googleClosureCompilationLevel = CompilationLevel.ADVANCED_OPTIMIZATIONS;
    mojo.googleClosureMap = true;

    Aggregation aggregation = new Aggregation();
    aggregation.setMinification(true);

    JavaScript javascript = new JavaScript();
    javascript.setAggregations(singletonList(new Aggregation()));
    mojo.javascript = javascript;

    mojo.execute();

    File map = new File(mojo.getDefaultOutputFile(aggregation).getParentFile(), "my-artifact-min.js.map");

    assertThat(mojo.getDefaultOutputFile(aggregation)).hasContent("\n//# sourceMappingURL=my-artifact-min.js.map");
    assertThat(map).exists();
    assertThat(lineIterator(map)).contains("\"file\":\"my-artifact-min.js\",");
}
 
Example #26
Source File: PomMojo.java    From tidy-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeForPom( String pom )
    throws MojoExecutionException, MojoFailureException
{
    try
    {
        String tidyPom = tidy( pom );
        fileWrite( getPomFile(), tidyPom );
    }
    catch ( IOException e )
    {
        throw new MojoExecutionException( "Failed to write the tidy POM.", e );
    }
}
 
Example #27
Source File: AbstractFMT.java    From fmt-maven-plugin with MIT License 5 votes vote down vote up
private JavaFormatterOptions.Style style() throws MojoFailureException {
  if ("aosp".equalsIgnoreCase(style)) {
    getLog().debug("Using AOSP style");
    return JavaFormatterOptions.Style.AOSP;
  }
  if ("google".equalsIgnoreCase(style)) {
    getLog().debug("Using Google style");
    return JavaFormatterOptions.Style.GOOGLE;
  }
  String message = "Unknown style '" + style + "'. Expected 'google' or 'aosp'.";
  getLog().error(message);
  throw new MojoFailureException(message);
}
 
Example #28
Source File: CreateExtensionMojoTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
void createExtensionUnderExistingPomWithAdditionalRuntimeDependencies() throws MojoExecutionException, MojoFailureException,
        IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, IOException {
    final CreateExtensionMojo mojo = initMojo(createProjectFromTemplate("create-extension-pom"));
    mojo.artifactId = "my-project-(add-to-bom)";
    mojo.assumeManaged = false;
    mojo.runtimeBomPath = Paths.get("boms/runtime/pom.xml");
    mojo.additionalRuntimeDependencies = Arrays.asList("org.example:example-1:1.2.3",
            "org.acme:acme-@{quarkus.artifactIdBase}:@{$}{acme.version}");
    mojo.execute();

    assertTreesMatch(Paths.get("src/test/resources/expected/create-extension-pom-add-to-bom"),
            mojo.basedir.toPath());
}
 
Example #29
Source File: UpdatePropertiesMojo.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * @param pom the pom to update.
 * @throws MojoExecutionException when things go wrong
 * @throws MojoFailureException when things go wrong in a very bad way
 * @throws XMLStreamException when things go wrong with XML streaming
 * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader)
 * @since 1.0-alpha-1
 */
protected void update( ModifiedPomXMLEventReader pom )
    throws MojoExecutionException, MojoFailureException, XMLStreamException
{
    Map<Property, PropertyVersions> propertyVersions =
        this.getHelper().getVersionPropertiesMap( getProject(), properties, includeProperties, excludeProperties,
                                                  autoLinkItems );
    for ( Map.Entry<Property, PropertyVersions> entry : propertyVersions.entrySet() )
    {
        Property property = entry.getKey();
        PropertyVersions version = entry.getValue();

        final String currentVersion = getProject().getProperties().getProperty( property.getName() );
        if ( currentVersion == null )
        {
            continue;
        }
        boolean canUpdateProperty = true;
        for ( ArtifactAssociation association : version.getAssociations() )
        {
            if ( !( isIncluded( association.getArtifact() ) ) )
            {
                getLog().info( "Not updating the property ${" + property.getName()
                    + "} because it is used by artifact " + association.getArtifact().toString()
                    + " and that artifact is not included in the list of " + " allowed artifacts to be updated." );
                canUpdateProperty = false;
                break;
            }
        }

        if ( canUpdateProperty )
        {
            int segment =
                determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates );
            updatePropertyToNewestVersion( pom, property, version, currentVersion, allowDowngrade, segment );
        }

    }
}
 
Example #30
Source File: MultiStartMojo.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    initProperties(true);
    initEnvironment();

    for (XmlPlexusConfiguration process : this.processes) {
        try {
            start(process);
        } catch (Exception e) {
            throw new MojoFailureException("Unable to start", e);
        }
    }
}