List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:de.bbe_consulting.mavento.helper.MagentoSqlUtil.java
License:Apache License
/** * Execute raw sql query via mysql exec. * // w w w . j ava 2s . c o m * @param query * @param cl * @param logger * @throws MojoExecutionException */ private static void executeRawSql(String query, Commandline cl, Log logger) throws MojoExecutionException { InputStream input = null; try { input = new ByteArrayInputStream(query.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new MojoExecutionException("Error: " + e.getMessage(), e); } final StringStreamConsumer output = new CommandLineUtils.StringStreamConsumer(); final StringStreamConsumer error = new CommandLineUtils.StringStreamConsumer(); try { final int returnValue = CommandLineUtils.executeCommandLine(cl, input, output, error); if (returnValue != 0) { logger.debug("retval: " + returnValue); logger.debug(output.getOutput().toString()); logger.debug(error.getOutput().toString()); throw new MojoExecutionException(error.getOutput().toString()); } else { logger.info("..done."); } } catch (CommandLineException e) { throw new MojoExecutionException("Error: " + e.getMessage(), e); } }
From source file:de.berlios.statcvs.xml.maven.JavaCommandLine.java
License:Apache License
/** * Dump the contents of the writer to the given logger instance. * /*from ww w. j ava 2 s .c o m*/ * @param logger output logger * @param writer writer containing lines to output */ public static void print(Log logger, Writer writer) { String string = writer.toString(); if (string != null && string.length() > 0) { StringReader sr = new StringReader(string); BufferedReader br = new BufferedReader(sr); try { while ((string = br.readLine()) != null) { logger.info(string); } } catch (IOException e) { logger.debug(e); } } }
From source file:de.kaiserpfalzEdv.maven.apacheds.ApacheDsLifecycle.java
License:Apache License
public void init(final Log logger) throws Exception { logger.info("Initializing Apache Directory Server ..."); this.logger = logger; DirectoryServiceFactory directoryFactory = new DefaultDirectoryServiceFactory(); directory = directoryFactory.getDirectoryService(); if (workingDirectory != null) { directory.setInstanceLayout(new InstanceLayout(workingDirectory)); }/*from w w w. j a v a2s .c om*/ logger.debug(directory.getInstanceLayout().toString()); directoryFactory.init("LDAP Integration Tester"); loadLdapSchema(logger); ldapServer = new LdapServer(); ldapServer.setTransports(new TcpTransport(port)); ldapServer.setDirectoryService(directory); server = new ApacheDS(ldapServer); loadAdditionalPartitions(); if (preload != null) { logger.info("Setting LDIF preload to: " + preload); server.setLdifDirectory(preload); } }
From source file:de.shadowhunt.maven.plugins.packageinfo.PackageInfoPlugin.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { final Log log = getLog(); if (isEmpty(annotationLines)) { log.warn("no annotationLines give: not generating any package-info.java files"); return;//www . j a va 2s . co m } try { for (final String compileSourceRoot : compileSourceRoots) { final File root = makeFileAbsolute(new File(compileSourceRoot)); log.debug("checking " + root + " for missing package-info.java files"); processFolder(root, root); } } catch (final IOException e) { throw new MojoExecutionException("could not generate package-info.java", e); } final File absoluteOutputDirectory = makeFileAbsolute(outputDirectory); final String outputPath = absoluteOutputDirectory.getAbsolutePath(); if (!project.getCompileSourceRoots().contains(outputPath)) { project.addCompileSourceRoot(outputPath); } }
From source file:de.smartics.maven.enforcer.rule.NoSnapshotsInDependencyManagementRule.java
License:Apache License
/** * {@inheritDoc}/*from w ww . j a v a2s.c om*/ */ public void execute(final EnforcerRuleHelper helper) throws EnforcerRuleException { final Log log = helper.getLog(); try { final MavenProject project = (MavenProject) helper.evaluate("${project}"); final boolean isSnapshot = project.getArtifact().isSnapshot(); if (onlyWhenRelease && isSnapshot) { log.info(getCacheId() + ": Skipping since not a release."); return; } final DependencyManagement dependencyManagement = project.getModel().getDependencyManagement(); if (dependencyManagement == null) { log.debug(getCacheId() + ": No dependency management block found."); return; } if (!checkOnlyResolvedDependencies) { final DependencyManagement originalDependencyManagement = project.getOriginalModel() .getDependencyManagement(); if (originalDependencyManagement != null) { final List<Dependency> declaredDependencies = originalDependencyManagement.getDependencies(); if (declaredDependencies != null && !declaredDependencies.isEmpty()) { checkDependenciesForSnapshots(helper, log, declaredDependencies); } } } final List<Dependency> dependencies = dependencyManagement.getDependencies(); if (dependencies == null || dependencies.isEmpty()) { log.debug(getCacheId() + ": No dependencies in dependency management block found."); return; } checkDependenciesForSnapshots(helper, log, dependencies); } catch (final ExpressionEvaluationException e) { throw new EnforcerRuleException("Unable to evaluate expression '" + e.getLocalizedMessage() + "'.", e); } }
From source file:de.smartics.maven.enforcer.rule.NoSnapshotsInDependencyManagementRule.java
License:Apache License
private void checkDependenciesForSnapshots(final EnforcerRuleHelper helper, final Log log, final List<Dependency> dependencies) throws EnforcerRuleException { final StringBuilder buffer = new StringBuilder(); for (final Dependency dependency : dependencies) { final String version = resolveVersion(helper, dependency); if (isSnapshot(version)) { buffer.append("\n ").append(version).append(": ").append(dependency); } else {//from w w w.j av a2 s. c o m log.debug(" Not a SNAPSHOT: " + dependency); } } if (buffer.length() > 0) { throw new EnforcerRuleException("Dependency Management contains SNAPSHOTS:" + buffer.toString() + "\n Please remove all SNAPSHOT dependencies!"); } }
From source file:de.tarent.maven.plugins.pkg.map.PackageMap.java
License:Open Source License
public void iterateDependencyArtifacts(Log l, Collection<Artifact> deps, Visitor v, boolean bundleNonExisting) { for (Iterator<Artifact> ite = deps.iterator(); ite.hasNext();) { Artifact a = ite.next();/* w ww . j a v a 2 s .co m*/ String aid = a.getArtifactId(); // Bundle dependencies which have been explicitly // marked as such. if (bundleOverrides.contains(aid)) { v.bundle(a); continue; } Entry e; try { e = mapping.getEntry(a.getGroupId(), aid, a.getSelectedVersion()); } catch (OverConstrainedVersionException e1) { throw new IllegalStateException("Unable to retrieve selected artifact version.", e1); } // If a distro is explicitly declared to have no packages everything // will be bundled (without warning). if (mapping.hasNoPackages) { v.bundle(a); } else if (e == null) { // If a package as not been declared a warning reminds to fix // the // package map. l.warn(mapping.distro + " has no entry for: " + a); if (bundleNonExisting) { v.bundle(a); } } else if (e.bundleEntry) { // If a package is explicitly said to be bundled this will be // done // without warning. v.bundle(a); } else if (e.ignoreEntry) { // If a package is explicitly said to be ignored this will be // done without warning. l.debug("Ignoring entry '" + e.artifactSpec + "', ignoreEntry flag is set"); } else { // Otherwise we have a plain dead easy Entry which needs to be // processed // somehow. v.visit(a, e); } } }
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 ww w . ja v a 2 s . c o 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 a va 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.Utils.java
License:Open Source License
/** * Copies the Artifacts contained in the set to the folder denoted by * <code>dst</code> and returns the amount of bytes copied. * /*from w ww . j a v a 2s . co m*/ * <p> * If an artifact is a zip archive it is unzipped in this folder. * </p> * * @param l * @param artifacts * @param dst * @return * @throws MojoExecutionException */ public static long copyArtifacts(Log l, Set<Artifact> artifacts, File dst) throws MojoExecutionException { long byteAmount = 0; if (artifacts.size() == 0) { l.info("no artifact to copy."); return byteAmount; } l.info("copying " + artifacts.size() + " dependency artifacts."); l.info("destination: " + dst.toString()); try { Iterator<Artifact> ite = artifacts.iterator(); while (ite.hasNext()) { Artifact a = (Artifact) ite.next(); l.info("copying artifact: " + a); File f = a.getFile(); if (f != null) { l.debug("from file: " + f); if (a.getType().equals("zip")) { // Assume that this is a ZIP file with native libraries // inside. // TODO: Determine size of all entries and add this // to the byteAmount. unpack(a.getFile(), dst); } else { FileUtils.copyFileToDirectory(f, dst); byteAmount += (long) f.length(); } } else { throw new MojoExecutionException( "Unable to copy Artifact " + a + " because it is not locally available."); } } } catch (IOException ioe) { throw new MojoExecutionException("IOException while copying dependency artifacts.", ioe); } return byteAmount; }