List of usage examples for org.apache.maven.cli MavenCli MavenCli
public MavenCli()
From source file:com.ibm.liberty.starter.it.api.v1.utils.MvnUtils.java
License:Apache License
public static int runMvnCommand(PrintStream outputStream, String tempDir, DownloadedZip zip, String... args) { String mvnMultiModuleProjectDirectory = tempDir + "/mvn/multi_module"; System.setProperty(MavenCli.MULTIMODULE_PROJECT_DIRECTORY, mvnMultiModuleProjectDirectory); MavenCli cli = new MavenCli(); return cli.doMain(args, zip.getLocation(), outputStream, outputStream); }
From source file:com.iyonger.apm.web.handler.GroovyMavenProjectScriptHandler.java
License:Apache License
@Override protected void prepareDistMore(Long testId, User user, FileEntry script, File distDir, PropertiesWrapper properties, ProcessingResultPrintStream processingResult) { String pomPathInSVN = PathUtils.join(getBasePath(script), "pom.xml"); MavenCli cli = new MavenCli(); processingResult.println("\nCopy dependencies by running 'mvn dependency:copy-dependencies" + " -DoutputDirectory=./lib -DexcludeScope=provided'"); int result = cli.doMain(new String[] { // goal specification "dependency:copy-dependencies", // run dependency goal "-DoutputDirectory=./lib", // to the lib folder "-DexcludeScope=provided" // but exclude the provided // library }, distDir.getAbsolutePath(), processingResult, processingResult); boolean success = (result == 0); if (success) { processingResult.printf("\nDependencies in %s was copied.\n", pomPathInSVN); LOGGER.info("Dependencies in {} is copied into {}/lib folder", pomPathInSVN, distDir.getAbsolutePath()); } else {/*from w ww.jav a2 s .com*/ processingResult.printf("\nDependencies copy in %s is failed.\n", pomPathInSVN); LOGGER.info("Dependencies copy in {} is failed.", pomPathInSVN); } // Then it's not necessary to include pom.xml anymore. FileUtils.deleteQuietly(new File(distDir, "pom.xml")); processingResult.setSuccess(result == 0); }
From source file:com.planet57.maven.shell.commands.maven.MavenCommand.java
License:Open Source License
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo();//from ww w .ja v a 2 s. co m Variables vars = context.getVariables(); CliRequestBuilder request = new CliRequestBuilder(); request.setArguments(strings(context.getArguments())); File baseDir = vars.get(SHELL_USER_DIR, File.class); request.setWorkingDirectory(baseDir); File projectDir = vars.get(MavenCli.MULTIMODULE_PROJECT_DIRECTORY, File.class, null); if (projectDir == null) { projectDir = findProjectDir(baseDir); } request.setProjectDirectory(projectDir); // Setup output colorization StreamSet current = StreamJack.current(); StreamSet streams; if (color == null || color) { // Complain if the user asked for color and its not supported if (color != null && !io.getTerminal().isAnsiSupported()) { log.warn("ANSI color is not supported by the current terminal"); } streams = new StreamSet(current.in, new ColorizingStream(current.out), new ColorizingStream(current.err)); } else { streams = current; } StreamJack.register(streams); int result = -1; try { MavenCli cli = new MavenCli(); result = cli.doMain(request.build()); } finally { StreamJack.deregister(); } return result; }
From source file:es.eucm.ead.exporter.AndroidExporter.java
License:Open Source License
public void export(String projectPath, String destination, Properties properties, boolean installAndDeploy) { // Copy android-pom.xml to android folder InputStream apkpom = ClassLoader.getSystemResourceAsStream("android-pom.xml"); InputStream manifest = generateManifest(properties); OutputStream os = null;// w w w. j a va 2s. c om try { File projectFolder = new File(projectPath); File mavenFolder = FileUtils.createTempDir("eadmaven", ""); File androidFolder = FileUtils.createTempDir("eadandroid", ""); FileUtils.deleteRecursive(androidFolder); androidFolder.mkdirs(); addTitle(mavenFolder, properties); addIcon(mavenFolder, properties); logger.info("Finished adding title & icon to {}", mavenFolder.getAbsolutePath()); FileUtils.copy(apkpom, new FileOutputStream(new File(mavenFolder, "pom.xml"))); FileUtils.copy(manifest, new FileOutputStream(new File(mavenFolder, "AndroidManifest.xml"))); logger.info("Added manifest and pom; now copying game assets..."); // Copy game assets to folder FileUtils.copyRecursive(projectFolder, androidFolder, androidFolder); // Copy engine assets to folder for (String s : R.RESOURCES) { InputStream ris = ClassLoader.getSystemResourceAsStream(s); OutputStream ros = null; try { String fileName = s.substring(s.lastIndexOf('/') + 1); String folder = s.substring(0, s.lastIndexOf('/')); File rf = new File(androidFolder.getAbsolutePath() + '/' + folder); rf.mkdirs(); ros = new FileOutputStream(new File(rf, fileName)); FileUtils.copy(ris, ros); } catch (Exception e) { logger.error("Problem copying resources {}", s, e); } finally { if (ris != null) { ris.close(); } if (ros != null) { ros.close(); } } } logger.info("... game assets & engine assets copied over"); String[] mavenArguments; if (installAndDeploy) { mavenArguments = new String[] { "-Dresources=" + androidFolder.getAbsolutePath(), "-Dandroid.sdk.path=" + properties.getProperty(SDK_HOME), "-X", "clean", "compile", "install", "android:deploy", "android:run" }; } else { mavenArguments = new String[] { "-Dresources=" + androidFolder.getAbsolutePath(), "-Dandroid.sdk.path=" + properties.getProperty(SDK_HOME), "-X", "clean", "compile", "install", }; } logger.info("Starting maven build of game .apk..."); MavenCli maven = new MavenCli(); maven.doMain(mavenArguments, mavenFolder.getAbsolutePath(), getStdOut(), getStdErr()); logger.info("... finished. Now copying .apk to final destination"); // Copy apk to destination if (destination != null) { File destinationFile = new File(destination); if (destinationFile.isDirectory()) { destinationFile = new File(destinationFile, "eAdventuregame.apk"); } else if (!destination.endsWith(".apk")) { destination += ".apk"; destinationFile = new File(destination); } FileUtils.copy(new File(mavenFolder.getAbsolutePath() + "/target", "game-android.apk"), destinationFile); } } catch (Exception e) { logger.error("Error exporting to apk", e); } finally { if (apkpom != null) { try { apkpom.close(); } catch (IOException e) { logger.error("", e); } } if (os != null) { try { os.close(); } catch (IOException e) { logger.error("", e); } } if (manifest != null) { try { manifest.close(); } catch (IOException e) { logger.error("", e); } } } }
From source file:es.eucm.ead.exporter.JarExporter.java
License:Open Source License
/** * @param projectFolder folder containing a folder (name as parameter 'resourcesFolder') with all the assets of the game * @param destination destination file to ouput the .jar *///from w w w.jav a 2s . c om public void export(String projectFolder, String destination, PrintStream out) { // Copy desktop-pom.xml to desktop folder InputStream jarpom = ClassLoader.getSystemResourceAsStream("desktop-pom.xml"); OutputStream os = null; try { File desktopFolder = FileUtils.createTempDir("eaddesktop", ""); desktopFolder.mkdirs(); // Copy pom to temp folder FileUtils.copy(jarpom, new FileOutputStream(new File(desktopFolder, "pom.xml"))); // Generate the jar with maven MavenCli maven = new MavenCli(); maven.doMain(new String[] { "-X", "-Dresources=" + projectFolder, "clean", "compile", "install", "assembly:single" }, desktopFolder.getAbsolutePath(), out, out); // Copy jar to destination File destinationFile = new File(destination); if (destinationFile.isDirectory()) { destinationFile = new File(destinationFile, "eAdventuregame.jar"); } else if (!destination.endsWith(".jar")) { destination += ".jar"; destinationFile = new File(destination); } // Copy to destination file if (destinationFile != null) { FileUtils.copy(new File(desktopFolder.getAbsolutePath() + "/target", "game-desktop-1.0-jar-with-dependencies.jar"), destinationFile); } } catch (Exception e) { } finally { if (jarpom != null) { try { jarpom.close(); } catch (IOException e) { } } if (os != null) { try { os.close(); } catch (IOException e) { } } } }
From source file:licenseUtil.Utils.java
License:Apache License
public static void writeEffectivePom(File projectDirectory, String fullEffectivePomFilename) { MavenCli cli = new MavenCli(); logger.info("Write effective-pom to \"" + fullEffectivePomFilename + "\""); cli.doMain(//w ww . jav a2s. c o m new String[] { "org.apache.maven.plugins:maven-help-plugin:2.2:effective-pom", "-Doutput=" + fullEffectivePomFilename }, projectDirectory.getAbsolutePath(), new PrintStream(new OutputStream() { public void write(int b) { //NO-OP } }), System.err); }
From source file:net.ssehub.easy.libs.maven.MavenPrg.java
License:Apache License
@Override public int execute(String[] args, String workingDirectory, PrintStream stdout, PrintStream stderr) { MavenCli cli = new MavenCli(); return cli.doMain(args, workingDirectory, System.out, System.out); }
From source file:org.apache.drill.exec.udf.dynamic.JarBuilder.java
License:Apache License
public JarBuilder(String projectDirectory) { this.cli = new MavenCli() { @Override//from w ww.ja va 2 s. c o m protected void customizeContainer(PlexusContainer container) { ((DefaultPlexusContainer) container).setLoggerManager(new BaseLoggerManager() { @Override protected org.codehaus.plexus.logging.Logger createLogger(String s) { return new Slf4jLogger(logger); } }); } }; this.projectDirectory = projectDirectory; }
From source file:org.echocat.jomon.maven.boot.ArtifactFactory.java
License:Mozilla Public License
protected MavenCli createCli(final AtomicReference<PlexusContainer> containerReference, final AtomicReference<DefaultMaven> oldMaven, final Maven maven) { return new MavenCli() { @Override/* ww w . java2s. c o m*/ protected void customizeContainer(PlexusContainer container) { try { oldMaven.set((DefaultMaven) container.lookup(Maven.class)); } catch (final ComponentLookupException e) { throw new RuntimeException(e); } container.addComponent(maven, Maven.class, ""); containerReference.set(container); } }; }
From source file:org.echocat.jomon.maven.MavenEnvironmentFactory.java
License:Mozilla Public License
@Nonnull protected MavenCli createCli(@Nonnull final AtomicReference<PlexusContainer> containerReference, @Nonnull final AtomicReference<DefaultMaven> oldMaven, final Maven maven) { return new MavenCli() { @Override/*from w w w. j a va 2s . c o m*/ protected void customizeContainer(PlexusContainer container) { try { oldMaven.set((DefaultMaven) container.lookup(Maven.class)); } catch (final ComponentLookupException e) { throw new RuntimeException(e); } container.addComponent(maven, Maven.class, ""); containerReference.set(container); } }; }