Properties userProperties = execEnv.getMavenSession().getUserProperties(); userProperties.setProperty("groupId", props.getGroupId()); userProperties.setProperty("artifactId", props.getArtifactId());
final Plugin globalJavadoc = executionEnvironment().getMavenProject().getPlugin("org.apache.maven.plugins:maven-javadoc-plugin"); if (null != globalJavadoc) executionEnvironment().getMavenProject().getBuild().removePlugin(globalJavadoc); executionEnvironment().getMavenProject().getBuild().addPlugin(globalJavadoc);
MavenSession session = env.getMavenSession(); MavenProject currentProject = env.getMavenSession().getCurrentProject(); if ((plugin.getVersion() == null || plugin.getVersion().length() == 0) && currentProject != null) { PluginManagement pm = currentProject.getPluginManagement(); env.getPluginManager().executeMojo(session, exec);
Properties sysProps = execEnv.getMavenSession().getExecutionProperties(); sysProps.setProperty("groupId",props.getGroupId()); sysProps.setProperty("artifactId",props.getArtifactId());
Properties sysProperties = execEnv.getMavenSession().getSystemProperties(); boolean skipThisMojo = sysProperties.containsKey("skipTests") || sysProperties.containsKey("skipITs") || List<String> goals = execEnv.getMavenSession().getGoals(); if (goals.contains("alfresco:run")) { sysProperties.put("skipTests", "true");
MavenSession session = env.getMavenSession(); MavenProject currentProject = env.getMavenSession().getCurrentProject(); if ((plugin.getVersion() == null || plugin.getVersion().length() == 0) && currentProject != null) { PluginManagement pm = currentProject.getPluginManagement(); env.getPluginManager().executeMojo(session, exec);
MojoExecutor.ExecutionEnvironment executionEnvironment) throws MojoExecutionException { Xpp3Dom goalConfig = getGoalConfig(plugin, goal, executionEnvironment.getMavenProject()); if (goalConfig == null) {
if (StringUtils.isNotBlank(a.latest)) { getLog().info("using stable product version: " + a.latest); getMavenContext().getExecutionEnvironment().getMavenSession().getExecutionProperties().setProperty(pid + "Version", a.latest); getMavenContext().getExecutionEnvironment().getMavenSession().getExecutionProperties().setProperty(pid + "DataVersion", a.data); getMavenContext().getExecutionEnvironment().getMavenSession().getExecutionProperties().setProperty(pid + "Version", stableVersion); getMavenContext().getExecutionEnvironment().getMavenSession().getExecutionProperties().setProperty(pid + "DataVersion", stableDataVersion);
Object repositorySession = getRepositorySession.invoke(session); BuildPluginManager pluginManager = env.getPluginManager();
MavenSession session = env.getMavenSession(); env.getPluginManager().loadPlugin( plugin, env.getMavenProject().getRemotePluginRepositories(), session.getRepositorySession()); env.getPluginManager().executeMojo(session, exec);
Object repositorySession = getRepositorySession.invoke(session); BuildPluginManager pluginManager = env.getPluginManager();
try { pluginDescriptor = MavenCompatibilityHelper.loadPluginDescriptor(plugin, executionEnvironment, executionEnvironment.getMavenSession()); } catch (MojoExecutionException e) {
@Override protected void doExecute() throws MojoExecutionException, MojoFailureException { trackFirstRunIfNeeded(); getGoogleTracker().track(GoogleAmpsTracker.CREATE_PLUGIN); String pid = getProductId(); Product ctx = getProductContexts().get(pid); AbstractProductHandler handler = createProductHandler(pid); getLog().info("determining latest stable product version..."); String stableVersion = getStableProductVersion(handler,ctx); if (StringUtils.isNotBlank(stableVersion)) { getLog().info("using latest stable product version: " + stableVersion); getMavenContext().getExecutionEnvironment().getMavenSession().getExecutionProperties().setProperty(pid + "Version", stableVersion); } getLog().info("determining latest stable data version..."); String stableDataVersion = getStableDataVersion(handler,ctx); if (StringUtils.isNotBlank(stableDataVersion)) { getLog().info("using latest stable data version: " + stableDataVersion); getMavenContext().getExecutionEnvironment().getMavenSession().getExecutionProperties().setProperty(pid + "DataVersion", stableDataVersion); } getMavenGoals().createPlugin(getProductId(), ampsCreatePluginPrompter); }
@Override public List<ProductArtifact> getAdditionalPlugins(Product ctx) throws MojoExecutionException { ArrayList<ProductArtifact> additionalPlugins = new ArrayList<>(); // Add the embedded elasticsearch plugin if (new DefaultArtifactVersion(ctx.getVersion()).compareTo(FIRST_SEARCH_VERSION) >= 0) { // The version of search distribution should be the same as the search plugin. projectLoader.loadMavenProject(context.getExecutionEnvironment().getMavenSession(), context.getProject(), artifactFactory.createParentArtifact(SERVER_GROUP_ID, "bitbucket-parent", ctx.getVersion())) .flatMap(mavenProject -> Optional.ofNullable(mavenProject.getDependencyManagement()) .flatMap(dependencyManager -> dependencyManager.getDependencies().stream() .filter(dep -> dep.getGroupId().equals(SEARCH_GROUP_ID)) .findFirst() .flatMap(dependency -> Optional.ofNullable(dependency.getVersion())))) .ifPresent(version -> additionalPlugins.add(new ProductArtifact(SEARCH_GROUP_ID, "embedded-elasticsearch-plugin", version))); } return additionalPlugins; }
/** * Wrap execute Mojo function for temporary removing global Cargo configuration * before starting AMPS internal Cargo */ @VisibleForTesting protected void executeMojoExcludeProductCargoConfig(Plugin internalCargo, String goal, Xpp3Dom configuration, ExecutionEnvironment env) throws MojoExecutionException { // remove application cargo plugin for avoiding amps standalone cargo merges configuration Plugin globalCargo = env.getMavenProject().getPlugin("org.codehaus.cargo:cargo-maven2-plugin"); env.getMavenProject().getBuild().removePlugin(globalCargo); env.executeMojo(internalCargo, goal, configuration); // restore application cargo plugin for maven next tasks if (null != globalCargo) { env.getMavenProject().getBuild().addPlugin(globalCargo); } }
private Artifact resolveArtifactForProduct(final ProductArtifact product) { final Artifact artifact = artifactFactory.createArtifact(product.getGroupId(), product.getArtifactId(), product.getVersion(), "compile", "obr"); try { final MavenSession session = context.getExecutionEnvironment().getMavenSession(); final MavenProject project = context.getExecutionEnvironment().getMavenProject(); final ArtifactResolver resolver = session.getContainer().lookup(ArtifactResolver.class); resolver.resolve(artifact, project.getRemoteArtifactRepositories(), session.getLocalRepository()); } catch (ArtifactNotFoundException | ArtifactResolutionException | ComponentLookupException e) { throw new RuntimeException(e); } return artifact; }
/** * Constructs the {@link ExecutionEnvironment} instance fluently * * @param mavenProject The current Maven project * @param mavenSession The current Maven session * @param pluginManager The Build plugin manager * @return The execution environment * @throws NullPointerException if mavenProject, mavenSession or pluginManager * are null */ public static ExecutionEnvironment executionEnvironment(MavenProject mavenProject, MavenSession mavenSession, BuildPluginManager pluginManager) { return new ExecutionEnvironment(mavenProject, mavenSession, pluginManager); }
/** * Constructs the {@link ExecutionEnvironment} instance fluently * * @param mavenProject The current Maven project * @param mavenSession The current Maven session * @param pluginManager The Build plugin manager * @return The execution environment * @throws NullPointerException if mavenProject, mavenSession or pluginManager * are null */ public static ExecutionEnvironment executionEnvironment(MavenProject mavenProject, MavenSession mavenSession, BuildPluginManager pluginManager) { return new ExecutionEnvironment(mavenProject, mavenSession, pluginManager); }
/** * Merges the properties: pom.xml overrides {@link AbstractProductHandlerMojo#setDefaultValues} overrides the Product Handler. * @param ctx the Product * @return the complete list of system properties */ protected final Map<String, String> mergeSystemProperties(Product ctx) { // Start from the base properties final Map<String, String> properties = new HashMap<>(getSystemProperties(ctx)); // Enter the System Property Variables from product context, overwriting duplicates ctx.getSystemPropertyVariables().forEach((key, value) -> properties.put(key, (String) value)); // Overwrite the default system properties with user input arguments Properties userProperties = context.getExecutionEnvironment().getMavenSession().getUserProperties(); userProperties.forEach((key, value) -> properties.put((String) key, (String) value)); return properties; }
/** * Constructs the {@link ExecutionEnvironment} instance fluently * * @param mavenSession The current Maven session * @param pluginManager The Build plugin manager * @return The execution environment * @throws NullPointerException if mavenProject, mavenSession or pluginManager * are null */ public static ExecutionEnvironment executionEnvironment(MavenSession mavenSession, BuildPluginManager pluginManager) { return new ExecutionEnvironment(mavenSession, pluginManager); }