Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2012 Reficio (TM) - Reestablish your software! All Rights Reserved.
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.reficio.p2;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.AbstractMojoExecutionException;
import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.eclipse.sisu.equinox.launching.internal.P2ApplicationLauncher;
import org.reficio.p2.bundler.ArtifactBundler;
import org.reficio.p2.bundler.ArtifactBundlerInstructions;
import org.reficio.p2.bundler.ArtifactBundlerRequest;
import org.reficio.p2.bundler.P2ArtifactMap;
import org.reficio.p2.bundler.impl.AquteBundler;
import org.reficio.p2.logger.Logger;
import org.reficio.p2.publisher.BundlePublisher;
import org.reficio.p2.publisher.CategoryPublisher;
import org.reficio.p2.resolver.eclipse.EclipseResolutionRequest;
import org.reficio.p2.resolver.eclipse.impl.DefaultEclipseResolver;
import org.reficio.p2.resolver.maven.Artifact;
import org.reficio.p2.resolver.maven.ArtifactResolutionRequest;
import org.reficio.p2.resolver.maven.ArtifactResolutionResult;
import org.reficio.p2.resolver.maven.ArtifactResolver;
import org.reficio.p2.resolver.maven.ResolvedArtifact;
import org.reficio.p2.resolver.maven.impl.AetherResolver;
import org.reficio.p2.utils.BundleUtils;
import org.reficio.p2.utils.JarUtils;
import org.reficio.p2.utils.Utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static java.util.Objects.requireNonNull;
/**
* Main plugin class
*
* @author Tom Bujok ([email protected])
* Reficio (TM) - Reestablish your software!
* http://www.reficio.org
* @since 1.0.0
*/
@Mojo(
name = "site",
defaultPhase = LifecyclePhase.COMPILE,
requiresDependencyResolution = ResolutionScope.RUNTIME,
requiresDependencyCollection = ResolutionScope.RUNTIME
)
public class P2Mojo extends AbstractMojo implements Contextualizable {
private static final String BUNDLES_TOP_FOLDER = "/source";
private static final String FEATURES_DESTINATION_FOLDER = BUNDLES_TOP_FOLDER + "/features";
private static final String BUNDLES_DESTINATION_FOLDER = BUNDLES_TOP_FOLDER + "/plugins";
private static final String DEFAULT_CATEGORY_FILE = "category.xml";
private static final String DEFAULT_CATEGORY_CLASSPATH_LOCATION = "/";
private String timestamp = Utils.getTimeStamp(); // create timestamp only once!
@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject project;
@Parameter(defaultValue = "${session}", required = true, readonly = true)
private MavenSession session;
@Component
@Requirement
private BuildPluginManager pluginManager;
@Parameter(defaultValue = "${project.build.directory}", required = true)
private String buildDirectory;
@Parameter(defaultValue = "${project.build.directory}/repository", required = true)
private String destinationDirectory;
@Component
@Requirement
private P2ApplicationLauncher launcher;
/**
* Specifies a file containing category definitions.
*/
@Parameter(defaultValue = "")
private String categoryFileURL;
/**
* Optional line of additional arguments passed to the p2 application launcher.
*/
@Parameter(defaultValue = "false")
private boolean pedantic;
/**
* Skip invalid artifacts.
*
*
* This flag controls if the processing should be continued on invalid artifacts. It defaults to false to keep the
* old behavior (break on invalid artifacts).
*/
@Parameter(defaultValue = "false")
private boolean skipInvalidArtifacts;
/**
* Skip not existing artifacts.
*
*
* This flag controls if the processing should be continued anyway, if an artifact does not exist. It defaults to
* false to keep the old behavior (break on not existing artifacts).
*/
@Parameter(defaultValue = "false")
private boolean skipNotExistingArtifacts;
/**
* Specifies whether to compress generated update site.
*/
@Parameter(defaultValue = "true")
private boolean compressSite;
/**
* Kill the forked process after a certain number of seconds. If set to 0, wait forever for the
* process, never timing out.
*/
@Parameter(defaultValue = "0", alias = "p2.timeout")
private int forkedProcessTimeoutInSeconds;
/**
* Specifies whether snapshot artifact timestamps should be reused
* This can result in inhomogenous naming of artifacts
*/
@Parameter(defaultValue = "true")
private boolean reuseSnapshotVersionFromArtifact;
/**
* Specifies additional arguments to p2Launcher, for example -consoleLog -debug -verbose
*/
@Parameter(defaultValue = "")
private String additionalArgs;
/**
* Skipe coming from embedded bnd tools should be skipped.
*
*
* This flag controls if the processing should be continued anyway, if the embedded bnd tool throws errors.
* It defaults to false to keep the old behavior (ignoring bnd tool errors).
*/
@Parameter(defaultValue = "true")
private boolean ignoreBndErrors;
/**
* Dependency injection container - used to get some components programatically
*/
private PlexusContainer container;
/**
* Aether Repository System
* Declared as raw Object type as different objects are injected in different Maven versions:
* * 3.0.0 and above -> org.sonatype.aether...
* * 3.1.0 and above -> org.eclipse.aether...
*/
private Object repoSystem;
/**
* The current repository/network configuration of Maven.
*/
@Parameter(defaultValue = "${repositorySystemSession}", readonly = true, required = true)
private Object repoSession;
/**
* The project's remote repositories to use for the resolution of project dependencies.
*/
@Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true)
private List