List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:de.tarent.maven.plugins.pkg.packager.IzPackPackager.java
License:Open Source License
private void createWindowsExecutable(Log l, String p7zipExec, File izPackHomeDir, File installerFile, File windowsInstallerFile) throws MojoExecutionException { l.info("calling izpack2exe.py to create Windows installer binary"); Utils.exec(new String[] { "python", "izpack2exe.py", "--file=" + installerFile.getAbsolutePath(), "--output=" + windowsInstallerFile.getAbsolutePath(), "--with-7z=" + p7zipExec, "--no-upx" }, new File(izPackHomeDir, "utils/izpack2exe"), "Unable to run izpack2exe script", "IOException while trying to run iz2pack2exe script."); }
From source file:de.tarent.maven.plugins.pkg.packager.IzPackPackager.java
License:Open Source License
private void createOSXExecutable(Log l, File izPackHomeDir, File installerFile, File osxInstallerFile) throws MojoExecutionException { l.info("calling izpack2app.py to create OS X installer binary"); Utils.exec(/*from w w w .j a v a 2s . c o m*/ new String[] { "python", "izpack2app.py", installerFile.getAbsolutePath(), osxInstallerFile.getAbsolutePath(), }, new File(izPackHomeDir, "utils/izpack2app"), "Unable to run izpack2app script", "IOException while trying to run iz2pack2app script."); }
From source file:de.tarent.maven.plugins.pkg.packager.RPMPackager.java
License:Open Source License
@Override public void execute(Log l, WorkspaceSession workspaceSession) throws MojoExecutionException { TargetConfiguration distroConfig = workspaceSession.getTargetConfiguration(); Helper ph = workspaceSession.getHelper(); // Configure the Helper for RPM use. ph.setStrategy(Helper.RPM_STRATEGY); ph.prepareInitialDirectories();/*from w ww . j a va2s .co m*/ // Setting all destination directories to /BUILD/ + target name ph.setDstSBinDir(new File(ph.getBaseBuildDir(), ph.getTargetSBinDir().toString())); ph.setDstBinDir(new File(ph.getBaseBuildDir(), ph.getTargetBinDir().toString())); ph.setDstSysconfDir(new File(ph.getBaseBuildDir(), ph.getTargetSysconfDir().toString())); ph.setDstDatarootDir(new File(ph.getBaseBuildDir(), ph.getTargetDatarootDir().toString())); ph.setDstDataDir(new File(ph.getBaseBuildDir(), ph.getTargetDataDir().toString())); ph.setDstJNIDir(new File(ph.getBaseBuildDir(), ph.getTargetJNIDir().toString())); ph.setDstBundledJarDir(new File(ph.getBaseBuildDir(), ph.getTargetBundledJarDir().toString())); ph.setDstStarterDir(new File(ph.getBaseBuildDir(), ph.getTargetStarterDir().toString())); ph.setDstWrapperScriptFile(new File(ph.getBaseBuildDir(), ph.getTargetWrapperScriptFile().toString())); ph.copyFiles(); l.debug(ph.getPackageName()); l.debug(ph.getPackageVersion()); l.debug(ph.getBasePkgDir().getPath()); // A set which will be filled with the artifacts which need to be // bundled with the // application. Set<Artifact> bundledArtifacts = null; Path bcp = new Path(); Path cp = new Path(); ArtifactInclusionStrategy aiStrategy = workspaceSession.getArtifactInclusionStrategy(); ArtifactInclusionStrategy.Result result = aiStrategy.processArtifacts(ph); // The user may want to avoid including dependencies if (distroConfig.isBundleDependencyArtifacts()) { bundledArtifacts = ph.bundleDependencies(result.getResolvedDependencies(), bcp, cp); ph.copyArtifacts(bundledArtifacts); } // Create classpath line, copy bundled jars and generate wrapper // start script only if the project is an application. if (distroConfig.getMainClass() != null) { // TODO: Handle native library artifacts properly. if (!distroConfig.isBundleDependencyArtifacts()) { ph.createClasspathLine(bcp, cp); } ph.generateWrapperScript(bcp, cp, false); } File specFile = new File(ph.getBaseSpecsDir(), ph.getPackageName() + ".spec"); try { generateSPECFile(l, ph, distroConfig, result.getResolvedDependencies(), specFile); l.info("SPEC file generated."); createPackage(l, workspaceSession, specFile); l.info("Package created."); File resultingPackage = copyRPMToTargetFolder(workspaceSession); l.info("Output of rpm -pqi :"); String out = IOUtils .toString(Utils.exec(new String[] { "rpm", "-pqi", resultingPackage.getAbsolutePath() }, resultingPackage.getParentFile(), "RPM not found", "RPM not found")); l.info("======================================="); for (String s : out.split("\\r?\\n")) { l.info(s); } l.info("======================================="); } catch (Exception ex) { throw new MojoExecutionException(ex.toString(), ex); } finally { try { ph.restoreRpmMacrosFileBackup(l); } catch (IOException e) { throw new MojoExecutionException(e.toString(), e); } } }
From source file:de.tarent.maven.plugins.pkg.packager.RPMPackager.java
License:Open Source License
/** * Copies the created artifact from//from w w w.j ava 2 s . c o m * * @param l * @param ph * @param distroConfig * @return * @throws IOException */ private File copyRPMToTargetFolder(WorkspaceSession ws) throws MojoExecutionException, IOException { Helper ph = ws.getHelper(); Log l = ws.getMojo().getLog(); StringBuilder rpmPackagePath = new StringBuilder(ph.getBaseBuildDir().getParent()); rpmPackagePath.append("/RPMS/"); rpmPackagePath.append(ph.getArchitecture()); rpmPackagePath.append("/"); String rpmPackageName = ph.getPackageFileName(); File targetFile = new File(ws.getMojo().getTempRoot().getParentFile(), rpmPackageName); l.debug("Attempting to copy from " + rpmPackagePath.toString() + rpmPackageName + " to " + targetFile.getAbsolutePath()); FileUtils.copyFile(new File(rpmPackagePath.toString(), rpmPackageName), targetFile); l.info("RPM file copied to " + targetFile.getAbsolutePath()); return targetFile; }
From source file:de.tarent.maven.plugins.pkg.packager.RPMPackager.java
License:Open Source License
/** * Will prepare the custom Build Area by creating the .rpmmacrosfile and * will check for rpmbuild to exist./*from ww w. j a va 2s . c om*/ */ @Override public void checkEnvironment(Log l, WorkspaceSession workspaceSession) throws MojoExecutionException { Helper ph = workspaceSession.getHelper(); checkneededfields(ph, workspaceSession.getTargetConfiguration()); try { Utils.checkProgramAvailability("gpg"); Utils.checkProgramAvailability("rpmbuild"); l.info(IOUtils.toString(Utils.exec(new String[] { "rpm", "--version" }, null, "Calling rpm --version failed", "ioError", null)).trim()); ph.createRpmMacrosFile(); } catch (IOException e) { throw new MojoExecutionException(e.getMessage()); } }
From source file:de.tarent.maven.plugins.pkg.packager.RPMPackager.java
License:Open Source License
/** * Takes the parameters inside Packaging.Helper and generates the spec file * needed for rpmbuild to work./* w ww. ja va2 s. com*/ * * @param l * @param ph * @param dc * @param specFile * @throws MojoExecutionException * @throws IOException */ private void generateSPECFile(Log l, Helper ph, TargetConfiguration dc, Set<Artifact> resolvedDependencies, File specFile) throws MojoExecutionException, IOException { l.info("Creating SPEC file: " + specFile.getAbsolutePath()); SpecFileGenerator sgen = new SpecFileGenerator(); sgen.setLogger(l); try { sgen.setLogger(l); sgen.setBuildroot("%{_builddir}"); // sgen.setCleancommands(generateCleanCommands(ph, dc)); // Following parameters MUST be provided for rpmbuild to work: l.info("Adding mandatory parameters to SPEC file."); sgen.setPackageName(ph.getPackageName()); sgen.setVersion(ph.getPackageVersion()); sgen.setSummary(ph.getProjectDescription()); sgen.setDescription(ph.getProjectDescription()); sgen.setLicense(ph.getLicense()); sgen.setRelease(dc.getRevision()); sgen.setSource(dc.getSource()); sgen.setUrl(ph.getProjectUrl()); sgen.setGroup(dc.getSection()); sgen.setDependencies(ph.createDependencyLine(resolvedDependencies)); // Following parameters are not mandatory l.info("Adding optional parameters to SPEC file."); sgen.setArch(ph.getArchitecture()); sgen.setPrefix(dc.getPrefix()); sgen.setPackager(dc.getMaintainer()); sgen.setFiles(ph.generateFilelist()); sgen.setPreinstallcommandsFromFile(ph.getSrcAuxFilesDir(), dc.getPreinstScript()); sgen.setPostinstallcommandsFromFile(ph.getSrcAuxFilesDir(), dc.getPostinstScript()); sgen.setPreuninstallcommandsFromFile(ph.getSrcAuxFilesDir(), dc.getPrermScript()); sgen.setPostuninstallcommandsFromFile(ph.getSrcAuxFilesDir(), dc.getPostrmScript()); l.info("Creating SPEC file: " + specFile.getAbsolutePath()); Utils.createFile(specFile, "spec"); sgen.generate(specFile); } catch (IOException ioe) { throw new MojoExecutionException("IOException while creating SPEC file.", ioe); } }
From source file:de.tarent.maven.plugins.pkg.packager.RPMPackager.java
License:Open Source License
/** * Executes rpmbuild, that will generate the final rpm package. * //from www .j a v a2 s .c o m * If the parameter "sign" is set as true in pom, package will be signed * with the Maintainer (Packager) name provided. * * @param l * @param ph * @param specFile * @throws MojoExecutionException */ private void createPackage(Log l, WorkspaceSession workspaceSession, File specFile) throws MojoExecutionException { Helper ph = workspaceSession.getHelper(); TargetConfiguration dc = workspaceSession.getTargetConfiguration(); AbstractPackagingMojo apm = workspaceSession.getMojo(); l.info("Calling rpmbuild to create binary package"); l.info("Builddir is " + ph.getBaseBuildDir().toString()); String[] command; if (dc.isSign()) { command = new String[] { "rpmbuild", "-bb", "--sign", "--buildroot", ph.getBaseBuildDir().toString(), specFile.toString() }; } else { command = new String[] { "rpmbuild", "-bb", "--buildroot", ph.getBaseBuildDir().toString(), specFile.toString() }; } if (apm.getSignPassPhrase() != null && dc.isSign()) { Utils.exec(command, "'rpmbuild -bb' failed.", "Error creating rpm file.", apm.getSignPassPhrase()); } else { Utils.exec(command, "'rpmbuild -bb' failed.", "Error creating rpm file."); } }
From source file:de.tarent.maven.plugins.pkg.signing.DebianSigner.java
License:Open Source License
/** * Actually signs the Debian-package using the command defined in the * <code>signCmd</code>-variable * //w w w . jav a 2s . c o m * @param l * @param base * @throws MojoExecutionException */ protected void signPackage(Log l, File base) throws MojoExecutionException { l.info("calling " + signCmd + " to sign package"); File pathToChangesFile = new File(base, packageFileNameWithoutExtension + ".changes"); /** * If a passphrase has been provided we will sign the package manually * with gpg and if not we will give the user the chance to enter the * passphrase manually (or to the agent to take control) */ if (!awaitUserInput && userInput != null) { Utils.exec( new String[] { "gpg", "--no-tty", "--passphrase", userInput, "--default-key", maintainer, "--no-use-agent", "--yes", "--clearsign", pathToChangesFile.getName() }, base, "Signing the changes-file failed.", "Error signing the changes-file."); try { FileUtils.copyFile(new File(pathToChangesFile + ".asc"), pathToChangesFile); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } } else { Utils.exec(new String[] { signCmd, pathToChangesFile.getAbsolutePath() }, base, "Signing the changes-file failed.", "Error signing the changes-file."); } l.info("changes-file signed successfully"); }
From source file:de.tarent.maven.plugins.pkg.signing.DebianSigner.java
License:Open Source License
/** * Executes the command defined in the <code>filesGenCmd</code>-variable to * generate a files-list.// ww w . ja va 2s . co m * * @param l * @param base * @throws MojoExecutionException */ protected void generateFileList(Log l, File base) throws MojoExecutionException { l.info("calling " + filesGenCmd + " to generate file-list"); /* * Workaround for newer dpkg-distaddfile which needs locking on * debian/control instead of DEBIAN/control * * we create debian/control temporary and remove it after DEBIAN/files * have been written */ File tempControlDir = new File(tempRoot.getParentFile(), "debian"); File tempControlFile = new File(tempControlDir, "control"); Utils.createFile(tempControlFile, "Could not create temporary debian/control file for " + filesGenCmd); File pathToFileListFile = new File(tempRoot, "files"); Utils.exec(new String[] { filesGenCmd, "-f" + pathToFileListFile.getAbsolutePath(), packageFileName, section, "optional" }, base, "Generating file-list failed.", "Error creating the file-list."); try { FileUtils.deleteDirectory(tempControlDir); } catch (IOException e) { throw new MojoExecutionException("Could not delte temporary debian/ directory for " + filesGenCmd); } }
From source file:de.tarent.maven.plugins.pkg.signing.DebianSigner.java
License:Open Source License
/** * Excecutes the command defined in the <code>rfc2822DateCmd</code>-variable * to generate a date-string complying to the RFC-2822 specification. * //from w w w.j av a2s . c om * @param l * @param base * @return * @throws MojoExecutionException */ protected String getRFC2822Date(Log l, File base) throws MojoExecutionException { l.info("calling 'date -R' to get RFC?2822 date"); InputStream processOutput = Utils.exec(new String[] { rfc2822DateCmd, "-R" }, base, "Generating RFC-2822 date failed", "Error generating RFC-2822 date."); if (processOutput != null) { try { return new BufferedReader(new InputStreamReader(processOutput)).readLine(); } catch (IOException e) { throw new MojoExecutionException("Generating RFC-2822 date failed. ", e); } } else { throw new MojoExecutionException( "Generating RFC-2822 date failed (No output from " + rfc2822DateCmd + ")."); } }