List of usage examples for org.apache.maven.plugin AbstractMojo getLog
@Override
public Log getLog()
Returns the logger that has been injected into this mojo.
From source file:com.excilys.ebi.gatling.mojo.GatlingJavaMainCallerInProcess.java
License:Apache License
public GatlingJavaMainCallerInProcess(AbstractMojo requester, String mainClassName, String classpath, String[] args) throws Exception { super(requester, mainClassName, classpath, null, args); //Pull out classpath and create class loader ArrayList<URL> urls = new ArrayList<URL>(); for (String path : classpath.split(File.pathSeparator)) { try {//from w ww. j a v a 2 s . c o m urls.add(new File(path).toURI().toURL()); } catch (MalformedURLException e) { requester.getLog().error(e); } } Thread.currentThread().setContextClassLoader(new URLClassLoader(urls.toArray(new URL[urls.size()]))); }
From source file:com.github.sdedwards.m2e_nar.internal.MavenUtils.java
License:Apache License
public static <T extends AbstractCompileMojo> NarExecution readSettings(final ConfiguratorContext context, final IMavenProjectFacade facade, final MojoExecution compileExecution, final Class<T> mojoType, final String buildType, final IProgressMonitor monitor) throws CoreException { final IMaven maven = context.getMaven(); final MavenProject mavenProject = facade.getMavenProject(); NarExecution settings = null;//from www .jav a 2 s. c o m if (compileExecution != null) { // Load plugin with Maven in order to check config // and to get at aol.properties resource inside the plugin AbstractMojo narMojo = loadMojo(maven, mavenProject, compileExecution, AbstractMojo.class, monitor); try { // ClassRealm pluginRealm = // compileExecution.getMojoDescriptor().getPluginDescriptor().getClassRealm(); // NarClassloader classloader = new NarClassloader(pluginRealm); // INarExecutionBuilder builder = // classloader.createNarExecutionBuilder(mavenProject, // compileMojo); // settings = builder.build(NarExecution.MAIN); T compileMojo = getConfiguredMojo(maven, mavenProject, compileExecution, mojoType, narMojo.getLog(), monitor); compileMojo.setNarProperties(new NarProperties(mavenProject, narMojo.getClass())); // Need to call validate to set up defaults compileMojo.validate(); // Resolve the NAR artifacts, possibly from workspace compileMojo.prepareNarArtifacts(context, facade, monitor); NarExecutionBuilder builder = new NarExecutionBuilder(compileMojo, compileExecution); settings = builder.build(buildType); } catch (MojoFailureException e) { throw new CoreException( new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't configure mojo")); } catch (MojoExecutionException e) { throw new CoreException( new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't configure mojo")); } finally { releaseMojo(maven, mavenProject, narMojo, compileExecution, monitor); } } else { throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't find default-nar-compile execution")); } return settings; }
From source file:io.gatling.mojo.GatlingJavaMainCallerInProcess.java
License:Apache License
public GatlingJavaMainCallerInProcess(AbstractMojo requester, String mainClassName, String classpath, String[] args) throws Exception { super(requester, mainClassName, classpath, null, args); // Pull out classpath and create class loader ArrayList<URL> urls = new ArrayList<URL>(); for (String path : classpath.split(File.pathSeparator)) { try {/*from w w w .j av a 2 s.c o m*/ urls.add(new File(path).toURI().toURL()); } catch (MalformedURLException e) { requester.getLog().error(e); } } // substitute classpath system prop oldClassPath = System.getProperty("java.class.path"); System.setProperty("java.class.path", classpath); // FIXME why not child of current classloader? // FIXME what about old classloader? Thread.currentThread().setContextClassLoader(new URLClassLoader(urls.toArray(new URL[urls.size()]))); }
From source file:iodp.usio.StreamReader.java
License:Apache License
public StreamReader(InputStream in, AbstractMojo mojo) { this.in = in; this.log = mojo.getLog(); }
From source file:org.apache.cayenne.tools.MavenLogger.java
License:Apache License
public MavenLogger(AbstractMojo parent) { this.logger = parent.getLog(); }
From source file:org.ops4j.pax.construct.lifecycle.SqueakyCleanMojo.java
License:Apache License
/** * Recover previously cached IDE files from the current Maven session * //from w w w .j ava 2 s .c o m * @param mojo currently executing mojo */ protected static void recoverMetaData(AbstractMojo mojo) { mojo.getLog().info("[recovering meta-data]"); String basedir = (String) mojo.getPluginContext().get("basedir"); // Restore generated files (previously removed during clean phase) before re-generation CacheUtils.pullFile(mojo, "MANIFEST.MF", new File(basedir, "META-INF/MANIFEST.MF")); CacheUtils.pullFile(mojo, ".project", new File(basedir, ".project")); CacheUtils.pullFile(mojo, ".classpath", new File(basedir, ".classpath")); }
From source file:org.ops4j.pax.construct.util.CacheUtils.java
License:Apache License
/** * Cache a text-based file inside the plugin context * //from ww w . j a va 2 s . c om * @param mojo currently executing mojo * @param key unique identifier * @param file text-based file */ public static void pushFile(AbstractMojo mojo, String key, File file) { if (file.exists()) { try { Reader input = StreamFactory.newPlatformReader(file); mojo.getPluginContext().put(key, IOUtil.toString(input)); IOUtil.close(input); } catch (IOException e) { mojo.getLog().warn("Unable to read file into cache: " + file); } } }
From source file:org.ops4j.pax.construct.util.CacheUtils.java
License:Apache License
/** * Restore a text-based file from the plugin context * /*from ww w . j a v a 2 s.c o m*/ * @param mojo currently executing mojo * @param key unique identifier * @param file text-based file */ public static void pullFile(AbstractMojo mojo, String key, File file) { String input = (String) mojo.getPluginContext().get(key); if (input != null) { try { file.getParentFile().mkdirs(); file.createNewFile(); Writer output = StreamFactory.newPlatformWriter(file); IOUtil.copy(input, output); IOUtil.close(output); } catch (IOException e) { mojo.getLog().warn("Unable to write file back from cache: " + file); } } }