List of usage examples for org.apache.maven.plugin AbstractMojo getPluginContext
@Override
public Map getPluginContext()
From source file:org.ops4j.pax.construct.lifecycle.SqueakyCleanMojo.java
License:Apache License
/** * Recover previously cached IDE files from the current Maven session * //ww w . j a v a2 s.c om * @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 * /* w w w . j av a 2 s. co m*/ * @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 w ww. j av a2s . c om * @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); } } }