List of usage examples for org.apache.maven.plugin.logging Log warn
void warn(Throwable error);
From source file:org.codehaus.mojo.smc.DotConvertor.java
License:Apache License
/** * Convert the specified .dot files to the specified formats using the graphviz tool * @param file/*from w w w . j a v a 2 s. co m*/ * @param format e.g. "png", "gif" * @param log */ public static int convert(File file, String format, Log log) throws CommandLineException { Commandline cl = new Commandline(); cl.setExecutable("dot"); cl.createArgument().setValue("-T" + format); cl.createArgument().setValue("-o"); cl.createArgument().setValue(file.getAbsolutePath().replace(".dot", "." + format)); cl.createArgument().setValue(file.getAbsolutePath()); log.debug("executing: " + cl.toString()); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine(cl, stdout, stderr); String output = stdout.getOutput(); if (output.length() > 0) { log.debug(output); } String errOutput = stderr.getOutput(); if (errOutput.length() > 0) { log.warn(errOutput); } return exitCode; }
From source file:org.codehaus.mojo.sysdeo.ide.IdeUtils.java
License:Apache License
public static Artifact resolveArtifactWithClassifier(String groupId, String artifactId, String version, String classifier, ArtifactRepository localRepository, ArtifactResolver artifactResolver, ArtifactFactory artifactFactory, List remoteRepos, Log log) { String type = classifier;// www.j a va 2 s. com // the "sources" classifier maps to the "java-source" type if ("sources".equals(type)) //$NON-NLS-1$ { type = "java-source"; //$NON-NLS-1$ } Artifact resolvedArtifact = artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier); try { artifactResolver.resolve(resolvedArtifact, remoteRepos, localRepository); } catch (ArtifactNotFoundException e) { // ignore, the jar has not been found } catch (ArtifactResolutionException e) { String message = Messages.getString("errorresolving", new Object[] { //$NON-NLS-1$ classifier, resolvedArtifact.getId(), e.getMessage() }); log.warn(message); } return resolvedArtifact; }
From source file:org.codehaus.mojo.unix.maven.MojoHelper.java
License:Open Source License
public static <UP extends UnixPackage<UP, PP>, PP extends UnixPackage.PreparedPackage> Execution create( Map platforms, String platformType, String formatType, MavenProjectWrapper project, boolean debug, boolean attachedMode, F<UP, UP> validateMojoSettingsAndApplyFormatSpecificSettingsToPackage, PackagingMojoParameters mojoParameters, final Log log) throws MojoFailureException, MojoExecutionException { PackagingFormat<UP> format = PackagingFormat.lookup(formatType); if (format == null) { throw new MojoFailureException("INTERNAL ERROR: could not find format: '" + formatType + "'."); }// w ww . j av a2 s. co m UnixPlatform platform = (UnixPlatform) platforms.get(platformType); if (platform == null) { throw new MojoFailureException("INTERNAL ERROR: could not find platform: '" + platformType + "'."); } /* // TODO: This is using a private Maven API that might change. Perhaps use some reflection magic here. String timestamp = snapshotTransformation.getDeploymentTimestamp(); */ // This chunk replaces the above getDeploymentTimestamp. However, it not ensure that all files get the // same timestamp. Need to look into how this is done with Maven 3 DateFormat utcDateFormatter = new SimpleDateFormat("yyyyMMdd.HHmmss"); utcDateFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); String timestamp = utcDateFormatter.format(new Date()); LocalFs buildDirectory = new LocalFs(project.buildDirectory); PackageVersion version = PackageVersion.packageVersion(project.version, timestamp, project.artifact.isSnapshot(), mojoParameters.revision); List<P3<UP, Package, List<AssemblyOperation>>> packages = nil(); for (Package pakke : validatePackages(mojoParameters.packages, attachedMode)) { try { String name = "unix/root-" + formatType + pakke.classifier.map(dashString).orSome(""); LocalFs packageRoot = buildDirectory.resolve(name); packageRoot.mkdir(); PackageParameters parameters = calculatePackageParameters(project, version, platform, mojoParameters, pakke); UP unixPackage = format.start(log).parameters(parameters).setVersion(version). // TODO: This should go away workingDirectory(packageRoot).debug(debug).basedir(project.basedir); // ----------------------------------------------------------------------- // Let the implementation add its metadata // ----------------------------------------------------------------------- unixPackage = validateMojoSettingsAndApplyFormatSpecificSettingsToPackage.f(unixPackage); // TODO: here the logic should be different if many packages are to be created. // Example: name should be taken from mojoParameters if there is only a single package, if not // it should come from the Pakke object. This should also be validated, at least for // name List<AssemblyOperation> assemblyOperations = createAssemblyOperations(project, parameters, unixPackage, project.basedir, buildDirectory, mojoParameters.assembly, pakke.assembly); // ----------------------------------------------------------------------- // Dump the execution // ----------------------------------------------------------------------- if (debug) { log.info("======================================================================="); log.info("Package parameters: " + parameters.id); log.info("Default file attributes: "); log.info(" File : " + parameters.defaultFileAttributes); log.info(" Directory : " + parameters.defaultDirectoryAttributes); log.info("Assembly operations: "); for (AssemblyOperation operation : assemblyOperations) { operation.streamTo(new AbstractLineStreamWriter() { protected void onLine(String line) { log.info(line); } }); } } packages = packages.cons(p(unixPackage, pakke, assemblyOperations)); } catch (UnknownArtifactException e) { Map map = new TreeMap<String, Artifact>(e.artifactMap); // TODO: Do not log here, throw a CouldNotFindArtifactException with the map as an argument log.warn("Could not find artifact:" + e.artifact); log.warn("Available artifacts:"); for (Object o : map.keySet()) { log.warn(o.toString()); } throw new MojoFailureException( "Unable to find artifact: '" + e.artifact + "'. See log for available artifacts."); } catch (MissingSettingException e) { String msg = "Missing required setting '" + e.getSetting() + "'"; if (!pakke.classifier.isNone()) { msg += ", for '" + pakke.classifier.some() + "'"; } msg += ", format '" + formatType + "'."; throw new MojoFailureException(msg); } catch (IOException e) { throw new MojoExecutionException("Error creating package " + (pakke.classifier.isSome() ? "classifier '" + pakke.classifier + "'" : "") + ", format '" + formatType + "'.", e); } } return new Execution<UP>(packages, project, formatType, attachedMode); }
From source file:org.codehaus.mojo.versions.api.PomHelper.java
License:Apache License
/** * Finds the local root of the specified project. * * @param project The project to find the local root for. * @param localRepository the local repo. * @param globalProfileManager the global profile manager. * @param logger The logger to log to. * @return The local root (note this may be the project passed as an argument). *///from www . j a v a 2s . c o m public static MavenProject getLocalRoot(MavenProjectBuilder builder, MavenProject project, ArtifactRepository localRepository, ProfileManager globalProfileManager, Log logger) { logger.info("Searching for local aggregator root..."); while (true) { final File parentDir = project.getBasedir().getParentFile(); if (parentDir.isDirectory()) { logger.debug("Checking to see if " + parentDir + " is an aggregator parent"); File parent = new File(parentDir, "pom.xml"); if (parent.isFile()) { try { final MavenProject parentProject = builder.build(parent, localRepository, globalProfileManager); if (getAllChildModules(parentProject, logger).contains(project.getBasedir().getName())) { logger.debug(parentDir + " is an aggregator parent"); project = parentProject; continue; } else { logger.debug(parentDir + " is not an aggregator parent"); } } catch (ProjectBuildingException e) { logger.warn(e); } } } logger.debug("Local aggregation root is " + project.getBasedir()); return project; } }
From source file:org.codehaus.mojo.webstart.generator.AbstractGenerator.java
License:Apache License
protected AbstractGenerator(Log log, GeneratorTechnicalConfig config, C extraConfig) { this.log = log; this.config = config; this.extraConfig = extraConfig; Properties props = new Properties(); String inputFileTemplatePath = config.getInputFileTemplatePath(); if (inputFileTemplatePath != null) { props.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogSystem"); props.setProperty("file.resource.loader.path", config.getResourceLoaderPath().getAbsolutePath()); initVelocity(props);//w w w. ja v a2s . c o m if (!engine.templateExists(inputFileTemplatePath)) { log.warn("Warning, template not found. Will probably fail."); } } else { log.info("No template specified Using default one."); inputFileTemplatePath = config.getDefaultTemplateResourceName(); String webstartJarURL = config.getWebstartJarURL(); log.debug("***** Webstart JAR URL: " + webstartJarURL); props = new Properties(); props.setProperty("resource.loader", "jar"); props.setProperty("jar.resource.loader.description", "Jar resource loader for default webstart templates"); props.setProperty("jar.resource.loader.class", "org.apache.velocity.runtime.resource.loader.JarResourceLoader"); props.setProperty("jar.resource.loader.path", webstartJarURL); initVelocity(props); if (!engine.templateExists(inputFileTemplatePath)) { log.error("Inbuilt template not found!! " + config.getDefaultTemplateResourceName() + " Will probably fail."); } } try { this.velocityTemplate = engine.getTemplate(inputFileTemplatePath, config.getEncoding()); } catch (Exception e) { IllegalArgumentException iae = new IllegalArgumentException( "Could not load the template file from '" + inputFileTemplatePath + "'"); iae.initCause(e); throw iae; } }
From source file:org.deegree.maven.CopyMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); if (files == null) { log.debug("No files configured."); return;//from w ww. j a v a2 s. c o m } File basedir = project.getBasedir(); for (Copy copy : files) { log.info("Copy " + copy.from + " to " + copy.to); File from = new File(basedir, copy.from); File to = new File(basedir, copy.to); if (!to.getParentFile().isDirectory() && !to.getParentFile().mkdirs()) { log.warn("Could not create parent directories for " + to + "."); continue; } try { copyFile(from, to); } catch (IOException e) { log.warn("Could not copy " + copy.from + " to " + copy.to + ": " + e.getLocalizedMessage()); log.debug(e); } } }
From source file:org.eclipse.hudson.maven.plugins.hpi.HpiUtil.java
License:Open Source License
static String findHudsonVersion(Collection<Artifact> artifacts, Log log) { for (Artifact a : artifacts) { if ((HUDSON_CORE_GROUP_ID.equals(a.getGroupId())) && HUDSON_CORE_ARTIFACT_ID.equals(a.getArtifactId())) { log.info("Targeting Hudson-Version: " + a.getVersion()); return a.getVersion(); }/* www.j av a 2 s . c om*/ } log.warn("Cannot determine Hudson-Version from project dependencies"); return null; }
From source file:org.eclipse.rcptt.maven.ExecuteMojo.java
License:Open Source License
private void setInjectionParams(Commandline cmd, Injection[] injections) { if (injections == null) { return;/* w ww . j a v a2s. co m*/ } final Log log = getLog(); for (Injection injection : injections) { final String site = injection.getSite(); if (site == null || site.length() == 0) { // <site> parameter is // missed or empty log.warn("Ingored injection with invalid site paramater."); continue; } final StringBuilder argValue = new StringBuilder(site); if (injection.getFeatures() != null) { // list of features is // specified for (String feature : injection.getFeatures()) { if (feature.length() == 0) { log.warn("Ingored empty name feature in the injection with site " + site); } argValue.append(INJECTION_FEATURE_SEP).append(feature); } } cmd.createArg().setValue(INJECTION); cmd.createArg().setValue(argValue.toString()); } if (aut.isIgnoreOtherInjections()) { cmd.createArg().setValue(IGNORE_OTHER_INJECTIONS); cmd.createArg().setValue(Boolean.toString(aut.isIgnoreOtherInjections())); } }
From source file:org.eluder.coveralls.maven.plugin.validation.ValidationErrors.java
License:Open Source License
public void throwOrInform(final Log log) { List<ValidationError> errors = filter(Level.ERROR); if (!errors.isEmpty()) { throw new ValidationException(errors.get(0).getMessage()); }/* w w w . j av a 2 s .co m*/ for (ValidationError error : filter(Level.WARN)) { log.warn(error.getMessage()); } }
From source file:org.everit.osgi.dev.maven.IntegrationTestMojo.java
License:Apache License
private void shutdownProcess(final Process process, final int shutdownTimeout, final int code) { getLog().warn("Stopping test process: " + process.getPid()); if (process.isRunning()) { if (process instanceof WindowsXPProcess) { // In case of windows xp process we must kill the process with a command as there is no // visible // window and kill tree command of YAJSW does not work. Hopefully this is a temporary // solution. Log log = getLog(); OperatingSystem operatingSystem = OperatingSystem.instance(); ProcessManager processManagerInstance = operatingSystem.processManagerInstance(); Process killProcess = processManagerInstance.createProcess(); String killCommand = "taskkill /F /T /PID " + process.getPid(); log.warn("Killing windows process with command: " + killCommand + ""); killProcess.setCommand(killCommand); killProcess.setVisible(false); killProcess.start();//from w ww .j a v a 2 s . c o m process.waitFor(shutdownTimeout); } else { process.stop(shutdownTimeout, code); } } }