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.DebPackager.java
License:Open Source License
private void createPackage(Log l, WorkspaceSession workspaceSession, File base, TargetConfiguration targetConfiguration) throws MojoExecutionException { l.info("calling dpkg-deb to create binary package"); Helper ph = workspaceSession.getHelper(); Utils.exec(/*w w w . ja v a 2 s. c om*/ new String[] { "fakeroot", "dpkg-deb", "--build", base.getName(), ph.getOutputDirectory().getAbsolutePath() }, base.getParentFile(), "'fakeroot dpkg --build' failed.", "Error creating the .deb file."); if (targetConfiguration.isSign()) { // This bundles the signature with the package bundleSignatureWithPackage(workspaceSession); /* * This creates a signed .changes file - needed when uploading to * repository. Unfortunatelly debsign, the program used to perform * this action won't allow entering the passphrase through an * automated process. TODO:Find a way to do this, or change the * packager executable to also sign */ DebianSigner db = new DebianSigner(workspaceSession, false); db.start(l); } }
From source file:de.tarent.maven.plugins.pkg.packager.IpkPackager.java
License:Open Source License
/** * Validates arguments and test tools.//from w w w . j ava 2s.com * * @throws MojoExecutionException */ public void checkEnvironment(Log l, WorkspaceSession workspaceSession) throws MojoExecutionException { TargetConfiguration targetConfiguration = workspaceSession.getTargetConfiguration(); boolean error = false; l.info("Maintainer : " + targetConfiguration.getMaintainer()); if (targetConfiguration.getMaintainer() == null) { l.error("The maintainer field of the distro configuration is not set, however this is mandatory for IPK packaging!"); error = true; } /* * The ipkg-build tool, needed by this class is delivered within this * package in the ipkg-utils-050831.tar.gz archive. It will be extracted * to a temporary location and deleted as soon as the vm exits. */ ArchiveFile IpkUtilsGZip; try { IpkUtilsGZip = new GZipTarFile( new File(IpkPackager.class.getResource("ipkg-utils-050831.tar.gz").toURI())); } catch (URISyntaxException ex) { throw new MojoExecutionException("Location for Zip file is malformed.", ex); } IPKGBUILD = Utils.getFileFromArchive(IpkUtilsGZip, "ipkg-utils-050831/ipkg-build"); // The tool needs to be executable IPKGBUILD.setExecutable(true); if (error) { throw new MojoExecutionException("Aborting due to earlier errors."); } }
From source file:de.tarent.maven.plugins.pkg.packager.IpkPackager.java
License:Open Source License
/** * Creates a control file whose dependency line can be provided as an * argument.// w ww. j av a 2 s . com * */ private void generateControlFile(Log l, Helper ph, TargetConfiguration dc, File controlFile, String packageName, String packageVersion, String dependencyLine, long byteAmount) throws MojoExecutionException { ControlFileGenerator cgen = new ControlFileGenerator(); cgen.setPackageName(packageName); cgen.setVersion(packageVersion); cgen.setSection(dc.getSection()); cgen.setDependencies(dependencyLine); cgen.setMaintainer(dc.getMaintainer()); cgen.setArchitecture(dc.getArchitecture()); cgen.setOE(packageName + "-" + packageVersion); String url = ph.getProjectUrl(); if (url == null) { l.warn("Project has no <url> field. However IPK packages require this. Using a dummy for now."); url = "http://not-yet-set.org/" + packageName; } cgen.setSource(url); cgen.setHomepage(url); String desc = ph.getProjectDescription(); if (desc == null) { l.warn("Project has no <description> field. However IPK packages require this. Using a placeholder for now."); desc = "No description given yet."; } cgen.setShortDescription(desc); l.info("creating control file: " + controlFile.getAbsolutePath()); Utils.createFile(controlFile, "control"); try { cgen.generate(controlFile); } catch (IOException ioe) { throw new MojoExecutionException("IOException while creating control file.", ioe); } }
From source file:de.tarent.maven.plugins.pkg.packager.IpkPackager.java
License:Open Source License
private void createPackage(Log l, Helper ph, File base) throws MojoExecutionException { l.info("calling ipkg-build to create binary package"); Utils.exec(/* www . j a v a 2 s . com*/ new String[] { IPKGBUILD.getAbsolutePath(), "-o", "root", "-g", "root", base.getName(), ph.getOutputDirectory().getAbsolutePath() }, base.getParentFile(), "'ipkg-build failed.", "Error creating the .ipk file."); }
From source file:de.tarent.maven.plugins.pkg.packager.IzPackDescriptor.java
License:Open Source License
void fillInfo(Log l, String appName, String appVersion, String url) { Node infoNode = doc.getElementsByTagName("info").item(0); if (!childExists(infoNode, "appname")) { l.info("setting <appname> to: " + appName); Node n = doc.createElement("appname"); n.setTextContent(appName);// www.j a v a2 s . c o m infoNode.appendChild(n); } if (!childExists(infoNode, "appversion")) { l.info("setting <appversion> to: " + appVersion); Node n = doc.createElement("appversion"); n.setTextContent(appVersion); infoNode.appendChild(n); } if (!childExists(infoNode, "appsubpath")) { l.info("setting <appsubpath> to: " + appName); Node n = doc.createElement("appsubpath"); n.setTextContent(appName); infoNode.appendChild(n); } if (!childExists(infoNode, "url")) { if (url == null) { l.warn("Neither the IzPack descriptor nor the POM contain a project URL!"); return; } l.info("setting <url> to: " + url); Node n = doc.createElement("url"); n.setTextContent(url); infoNode.appendChild(n); } }
From source file:de.tarent.maven.plugins.pkg.packager.IzPackPackager.java
License:Open Source License
public void execute(Log l, WorkspaceSession workspaceSession) throws MojoExecutionException { TargetConfiguration distroConfig = workspaceSession.getTargetConfiguration(); Helper ph = workspaceSession.getHelper(); // The root directory into which everything from srcRoot is copied // into (inside the outputDirectory). File packagingBaseDir = new File(workspaceSession.getMojo().getTempRoot(), "izpack-packaging"); ph.setBasePkgDir(packagingBaseDir);/* w ww . ja v a2 s .c om*/ ph.setDstAuxDir(packagingBaseDir); ph.setTargetSysconfDir(new File("${INSTALL_PATH}")); ph.setDstSysconfDir(packagingBaseDir); ph.setTargetDatarootDir(new File("${INSTALL_PATH}")); ph.setDstDatarootDir(packagingBaseDir); ph.setTargetDataDir(new File("${INSTALL_PATH}")); ph.setDstDataDir(packagingBaseDir); // The root directory into which the jars from the dependencies // are put. ph.setDstBundledJarDir(new File(packagingBaseDir, "lib")); ph.setTargetBundledJarDir(new File("%{INSTALL_PATH}", "lib")); // Sets where to copy the JNI libraries ph.setTargetJNIDir(new File("%{INSTALL_PATH}", "lib")); ph.setDstJNIDir(new File(packagingBaseDir, "lib")); // Overrides default dst artifact file. ph.setDstArtifactFile(new File(ph.getDstBundledJarDir(), ph.getArtifactId() + ".jar")); // The root directory into which the starter and the classpath // properties file are put. ph.setDstStarterDir(new File(packagingBaseDir, "_starter")); ph.setTargetStarterDir(new File("%{INSTALL_PATH}", "_starter")); // The XML file for IzPack which describes how to generate the // installer. File installerXmlFile = new File(packagingBaseDir, distroConfig.getIzPackInstallerXml()); File modifiedInstallerXmlFile = new File(packagingBaseDir, "modified-" + distroConfig.getIzPackInstallerXml()); // The resulting Jar file which contains the runnable installer. File resultFile = new File(ph.getOutputDirectory(), ph.getPackageName() + "-" + ph.getPackageVersion() + "-installer.jar"); File resultFileWindows = new File(ph.getOutputDirectory(), ph.getPackageName() + "-" + ph.getPackageVersion() + "-installer.exe"); File resultFileOSX = new File(ph.getOutputDirectory(), ph.getPackageName() + "-" + ph.getPackageVersion() + "-installer.app"); // targetBinDir does not occur within any script. Therefore there is no // need to // fumble with ${INSTALL_PATH}. The targetBinDir property will still be // used to create // dstWrapperScriptFile but by setting it to "" it does not have any // negative effect. // TODO: By splitting the target/dst variants from the actual filename // this could // implemented more elegantly. ph.setTargetBinDir(new File("")); ph.setDstBinDir(packagingBaseDir); File wrapperScriptFile = ph.getDstWrapperScriptFile(); File windowsWrapperScriptFile = ph.getDstWindowsWrapperScriptFile(); // The destination file for the embedded IzPack installation. File izPackEmbeddedJarFile = new File(workspaceSession.getMojo().getTempRoot(), IZPACK_EMBEDDED_JAR); // The directory in which the embedded IzPack installation is unpacked // at runtime. File izPackEmbeddedRoot = new File(workspaceSession.getMojo().getTempRoot(), "izpack-embedded"); Set<Artifact> bundledArtifacts = null; Path bcp = new Path(); Path cp = new Path(); Set<Artifact> deps = ph.resolveProjectDependencies(); prepareDirectories(l, workspaceSession.getMojo().getTempRoot(), izPackEmbeddedRoot, ph.getSrcIzPackFilesDir(), packagingBaseDir, ph.getDstBundledJarDir()); unpackIzPack(l, izPackEmbeddedJarFile, izPackEmbeddedRoot); // IzPack does not support the exclusion of dependencies. bundledArtifacts = ph.bundleDependencies(deps, bcp, cp); ph.copyArtifacts(bundledArtifacts); ph.copyProjectArtifact(); ph.copyFiles(); l.info("parsing installer xml file: " + installerXmlFile); IzPackDescriptor desc = new IzPackDescriptor(installerXmlFile, "Unable to parse installer xml file."); l.info("adding/modifying basic information"); desc.fillInfo(l, ph.getPackageName(), ph.getPackageVersion(), ph.getProjectUrl()); desc.removeAotPack(); ph.generateWrapperScript(bcp, cp, true); if (distroConfig.isAdvancedStarter()) { desc.addStarter("_starter", "_classpath"); } l.info("adding wrapper script information."); desc.addUnixWrapperScript(wrapperScriptFile.getName(), ph.getProjectDescription()); desc.addWindowsWrapperScript(windowsWrapperScriptFile.getName(), ph.getProjectDescription()); l.info("writing modified installer xml file."); desc.finish(modifiedInstallerXmlFile, "Unable to write modified installer xml file."); createInstaller(l, ph.getJavaExec(), izPackEmbeddedRoot, packagingBaseDir, modifiedInstallerXmlFile, resultFile); if (distroConfig.isCreateWindowsExecutable()) { createWindowsExecutable(l, ph.get7ZipExec(), izPackEmbeddedRoot, resultFile, resultFileWindows); } if (distroConfig.isCreateOSXApp()) { createOSXExecutable(l, izPackEmbeddedRoot, resultFile, resultFileOSX); } /* * When the Mojo fails to complete its task the work directory will be * left in an unclean state to make it easier to debug problems. * * However the work dir will be cleaned up when the task is run next * time. */ }
From source file:de.tarent.maven.plugins.pkg.packager.IzPackPackager.java
License:Open Source License
/** * Validates arguments and tests tools./*from w w w .j a v a 2s . com*/ * * @throws MojoExecutionException */ public void checkEnvironment(Log l, WorkspaceSession workspaceSession) throws MojoExecutionException { Helper ph = workspaceSession.getHelper(); TargetConfiguration targetConfiguration = workspaceSession.getTargetConfiguration(); l.info("java executable : " + ph.getJavaExec()); l.info("7zip executable : " + ph.get7ZipExec()); l.info("create OS X app : " + (targetConfiguration.isCreateOSXApp() ? "yes" : "no")); l.info("create Windows setup file: " + (targetConfiguration.isCreateWindowsExecutable() ? "yes" : "no")); Utils.checkProgramAvailability(ph.getJavaExec()); if (targetConfiguration.isCreateWindowsExecutable()) { Utils.checkProgramAvailability(ph.get7ZipExec()); } }
From source file:de.tarent.maven.plugins.pkg.packager.IzPackPackager.java
License:Open Source License
/** * Creates the temporary and package base directory. * /*from w ww . j a va2s. c o m*/ * @param l * @param basePkgDir * @throws MojoExecutionException */ private void prepareDirectories(Log l, File tempRoot, File izPackEmbeddedRoot, File srcDir, File tempDescriptorRoot, File libraryRoot) throws MojoExecutionException { l.info("creating temporary directory: " + tempRoot.getAbsolutePath()); if (!tempRoot.exists() && !tempRoot.mkdirs()) { throw new MojoExecutionException("Could not create temporary directory."); } l.info("cleaning the temporary directory"); try { FileUtils.cleanDirectory(tempRoot); } catch (IOException ioe) { throw new MojoExecutionException("Exception while cleaning temporary directory.", ioe); } l.info("creating IzPack base directory: " + izPackEmbeddedRoot.getAbsolutePath()); if (!izPackEmbeddedRoot.mkdirs()) { throw new MojoExecutionException("Could not create directory for the embedded IzPack installation."); } if (!tempDescriptorRoot.mkdirs()) { throw new MojoExecutionException("Could not create base directory for the IzPack descriptor."); } l.info("copying IzPack descriptor data"); try { FileUtils.copyDirectory(srcDir, tempDescriptorRoot, Utils.FILTER); } catch (IOException ioe) { throw new MojoExecutionException("IOException while copying IzPack descriptor data.", ioe); } l.info("creating directory for dependencies: " + libraryRoot.getAbsolutePath()); if (!libraryRoot.mkdirs()) { throw new MojoExecutionException("Could not create directory for the dependencies."); } }
From source file:de.tarent.maven.plugins.pkg.packager.IzPackPackager.java
License:Open Source License
/** * Puts the embedded izpack jar from the (resource) classpath into the work * directory and unpacks it there.//from www . ja va 2 s . c o m * * @param l * @param izPackEmbeddedFile * @param izPackEmbeddedHomeDir * @throws MojoExecutionException */ private void unpackIzPack(Log l, File izPackEmbeddedFile, File izPackEmbeddedHomeDir) throws MojoExecutionException { l.info("storing embedded IzPack installation in " + izPackEmbeddedFile); Utils.storeInputStream(IzPackPackager.class.getResourceAsStream(IZPACK_EMBEDDED_JAR), izPackEmbeddedFile, "IOException while unpacking embedded IzPack installation."); l.info("unzipping embedded IzPack installation to" + izPackEmbeddedHomeDir); int count = 0; ZipFile zip = null; try { zip = new ZipFile(izPackEmbeddedFile); Enumeration<? extends ZipEntry> e = zip.entries(); while (e.hasMoreElements()) { count++; ZipEntry entry = (ZipEntry) e.nextElement(); File unpacked = new File(izPackEmbeddedHomeDir, entry.getName()); if (entry.isDirectory()) { unpacked.mkdirs(); // TODO: Check success. } else { Utils.createFile(unpacked, "Unable to create ZIP file entry "); Utils.storeInputStream(zip.getInputStream(entry), unpacked, "IOException while unpacking ZIP file entry."); } } } catch (IOException ioe) { throw new MojoExecutionException("IOException while unpacking embedded IzPack installation.", ioe); } finally { if (zip != null) { try { zip.close(); } catch (IOException e) { l.info(String.format("Error at closing zipfile %s caused by %s", izPackEmbeddedFile.getName(), e.getMessage())); } } } l.info("unpacked " + count + " entries"); }
From source file:de.tarent.maven.plugins.pkg.packager.IzPackPackager.java
License:Open Source License
private void createInstaller(Log l, String javaExec, File izPackHomeDir, File izPackBaseDir, File izPackDescriptorFile, File izPackInstallerFile) throws MojoExecutionException { l.info("calling IzPack compiler to create installer package"); // Command-line argument ordering and naming suitable for IzPack 3.9.0 Utils.exec(/*w w w . j av a2s . c o m*/ new String[] { javaExec, "-jar", izPackHomeDir.getAbsolutePath() + "/lib/compiler.jar", izPackDescriptorFile.getAbsolutePath(), "-h", izPackHomeDir.getAbsolutePath(), "-b", izPackBaseDir.getAbsolutePath(), "-o", izPackInstallerFile.getAbsolutePath() }, izPackHomeDir, "Unable to run IzPack.", "IOException while trying to run IzPack."); }