List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:org.codehaus.mojo.versions.api.PomHelper.java
License:Apache License
/** * Modifies the collection of child modules removing those which cannot be found relative to the parent. * * @param logger The logger to log to. * @param basedir the project basedir. * @param childModules the child modules. *//* ww w. j a v a 2 s . co m*/ public static void removeMissingChildModules(Log logger, File basedir, Collection<String> childModules) { logger.debug("Removing child modules which are missing..."); Iterator<String> i = childModules.iterator(); while (i.hasNext()) { String modulePath = i.next(); File moduleFile = new File(basedir, modulePath); if (moduleFile.isDirectory() && new File(moduleFile, "pom.xml").isFile()) { // it's a directory that exists continue; } if (moduleFile.isFile()) { // it's the pom.xml file directly referenced and it exists. continue; } logger.debug("Removing missing child module " + modulePath); i.remove(); } debugModules(logger, "After removing missing", childModules); }
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 w w w . j ava 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);//ww w. ja v a 2s . 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.codehaus.mojo.xmlbeans.SchemaArtifact.java
License:Apache License
/** * Assuming that the artifact has a file handle, returns a collection of strings * pointing to each xsd file within the jar. * * @return Collection of xsd file paths relative to the jar file. * @number MXMLBEANS-21//ww w . jav a 2 s . c o m */ public static Map getFilePaths(Artifact artifact, Log logger, File prefix) throws XmlBeansException { Map xsds = new HashMap(); File artifactFile = artifact.getFile(); List nextSet; if (artifactFile != null) { try { FilteredJarFile jarFile = new FilteredJarFile(artifactFile, logger); nextSet = jarFile.getEntryPathsAndExtract(XSD_SUFFIXES, prefix); String fileName; for (Iterator i = nextSet.iterator(); i.hasNext();) { fileName = (String) i.next(); if (logger.isDebugEnabled()) { logger.debug("Adding " + fileName + "from an artifact."); } xsds.put(fileName, new File(prefix, fileName)); } } catch (IOException ioe) { throw new XmlBeansException(XmlBeansException.XSD_ARTIFACT_JAR, ioe); } } else { throw new XmlBeansException(XmlBeansException.ARTIFACT_FILE_PATH, artifact.toString()); } return xsds; }
From source file:org.commonjava.maven.plugins.projectsrc.ProjectSourcesGoal.java
License:Apache License
/** * Returns true if the current project is located at the Execution Root Directory (where mvn was launched) * // www . j a va 2s .co m * @return */ private boolean isThisTheExecutionRoot() { final Log log = getLog(); log.debug("Root Folder:" + mavenSession.getExecutionRootDirectory()); log.debug("Current Folder:" + basedir); final boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase(basedir.toString()); if (result) { log.debug("This is the execution root."); } else { log.debug("This is NOT the execution root."); } return result; }
From source file:org.commonjava.tensor.maven.plugin.LogProjectBuildroot.java
License:Apache License
protected boolean isThisTheExecutionRoot() { final Log log = getLog(); log.debug("Root Folder:" + session.getExecutionRootDirectory()); log.debug("Current Folder:" + basedir); final boolean result = session.getExecutionRootDirectory().equalsIgnoreCase(basedir.toString()); if (result) { log.debug("This is the execution root."); } else {//from w ww.j a va 2 s . c o m log.debug("This is NOT the execution root."); } return result; }
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 w w . java2s . com } 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.deegree.maven.WorkspaceMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); File dir = determineWorkspaceDirectory(); ZipOutputStream out = null;/*w ww . j av a 2s. c o m*/ try { Set<?> artifacts = getDependencyArtifacts(project, artifactResolver, artifactFactory, metadataSource, localRepository, "deegree-workspace", true); List<Artifact> workspaces = new ArrayList<Artifact>(); for (Object o : artifacts) { workspaces.add((Artifact) o); } reverse(workspaces); Set<?> jarDeps = getDependencyArtifacts(project, artifactResolver, artifactFactory, metadataSource, localRepository, "jar", false); File target = new File(project.getBasedir(), "target"); if (!target.exists() && !target.mkdirs()) { throw new MojoFailureException("Could not create target directory!"); } File workspaceFile = new File(project.getBasedir(), "target/" + project.getArtifactId() + "-" + project.getVersion() + ".deegree-workspace"); OutputStream os = new FileOutputStream(workspaceFile); out = new ZipOutputStream(os); HashSet<String> visitedFiles = new HashSet<String>(); ZipUtils.zip(dir, out, dir.getAbsoluteFile().toURI(), visitedFiles); ZipUtils.zipModules(jarDeps, visitedFiles, out); ZipUtils.zipJarDependencies(jarDeps, log, visitedFiles, out); ZipUtils.integrateWorkspaces(workspaces, log, target, out, visitedFiles); attachArtifact(log, workspaceFile); } catch (Throwable e) { log.debug(e); throw new MojoFailureException("Could not create workspace zip artifact: " + e.getLocalizedMessage()); } finally { closeQuietly(out); } }
From source file:org.dthume.maven.xpom.mojo.ProjectMojo.java
License:Apache License
private Model getModel() { final Log log = getLog(); Model model = null;/*w w w . j a va 2 s . c o m*/ if (isUseEffectiveModel()) { log.debug("Using effective project model"); model = getProject().getModel(); } else { log.debug("Using original project Model"); model = getProject().getOriginalModel(); } if (log.isDebugEnabled()) log.debug("Model=" + model); return model; }
From source file:org.eclipse.acceleo.maven.AcceleoParserMojo.java
License:Open Source License
/** * {@inheritDoc}//from ww w . j a v a 2 s .co m * * @see org.apache.maven.plugin.AbstractMojo#execute() */ public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); log.info("Acceleo maven stand alone build..."); log.info("Starting packages registration..."); URLClassLoader newLoader = null; try { List<?> runtimeClasspathElements = project.getRuntimeClasspathElements(); List<?> compileClasspathElements = project.getCompileClasspathElements(); URL[] runtimeUrls = new URL[runtimeClasspathElements.size() + compileClasspathElements.size()]; int i = 0; for (Object object : runtimeClasspathElements) { if (object instanceof String) { String str = (String) object; log.debug("Adding the runtime dependency " + str + " to the classloader for the package resolution"); runtimeUrls[i] = new File(str).toURI().toURL(); i++; } else { log.debug("Runtime classpath entry is not a string: " + object); } } for (Object object : compileClasspathElements) { if (object instanceof String) { String str = (String) object; log.debug("Adding the compilation dependency " + str + " to the classloader for the package resolution"); runtimeUrls[i] = new File(str).toURI().toURL(); i++; } else { log.debug("Runtime classpath entry is not a string: " + object); } } newLoader = new URLClassLoader(runtimeUrls, Thread.currentThread().getContextClassLoader()); } catch (DependencyResolutionRequiredException e) { log.error(e); } catch (MalformedURLException e) { log.error(e); } for (String packageToRegister : this.packagesToRegister) { try { if (newLoader != null) { Class<?> forName = Class.forName(packageToRegister, true, newLoader); Field nsUri = forName.getField("eNS_URI"); Field eInstance = forName.getField("eINSTANCE"); Object nsURIInvoked = nsUri.get(null); if (nsURIInvoked instanceof String) { log.info("Registering package '" + packageToRegister + "'."); AcceleoPackageRegistry.INSTANCE.put((String) nsURIInvoked, eInstance.get(null)); } else { log.error("The URI field is not a string."); } } } catch (ClassNotFoundException e) { log.error(e); } catch (IllegalAccessException e) { log.error(e); } catch (SecurityException e) { log.error(e); } catch (NoSuchFieldException e) { log.error(e); } } log.info("Starting the build sequence for the project '" + this.acceleoProject.getRoot() + "'..."); log.info("Mapping the pom.xml to AcceleoProject..."); Preconditions.checkNotNull(this.acceleoProject); Preconditions.checkNotNull(this.acceleoProject.getRoot()); Preconditions.checkNotNull(this.acceleoProject.getEntries()); Preconditions.checkState(this.acceleoProject.getEntries().size() >= 1); File root = this.acceleoProject.getRoot(); org.eclipse.acceleo.internal.parser.compiler.AcceleoProject aProject = new org.eclipse.acceleo.internal.parser.compiler.AcceleoProject( root); List<Entry> entries = this.acceleoProject.getEntries(); Set<AcceleoProjectClasspathEntry> classpathEntries = new LinkedHashSet<AcceleoProjectClasspathEntry>(); for (Entry entry : entries) { File inputDirectory = new File(root, entry.getInput()); File outputDirectory = new File(root, entry.getOutput()); log.debug("Input: " + inputDirectory.getAbsolutePath()); log.debug("Output: " + outputDirectory.getAbsolutePath()); AcceleoProjectClasspathEntry classpathEntry = new AcceleoProjectClasspathEntry(inputDirectory, outputDirectory); classpathEntries.add(classpathEntry); } aProject.addClasspathEntries(classpathEntries); List<AcceleoProject> dependencies = this.acceleoProject.getDependencies(); if (dependencies != null) { for (AcceleoProject dependingAcceleoProject : dependencies) { File dependingProjectRoot = dependingAcceleoProject.getRoot(); Preconditions.checkNotNull(dependingProjectRoot); org.eclipse.acceleo.internal.parser.compiler.AcceleoProject aDependingProject = new org.eclipse.acceleo.internal.parser.compiler.AcceleoProject( dependingProjectRoot); List<Entry> dependingProjectEntries = dependingAcceleoProject.getEntries(); Set<AcceleoProjectClasspathEntry> dependingClasspathEntries = new LinkedHashSet<AcceleoProjectClasspathEntry>(); for (Entry entry : dependingProjectEntries) { File inputDirectory = new File(root, entry.getInput()); File outputDirectory = new File(root, entry.getOutput()); AcceleoProjectClasspathEntry classpathEntry = new AcceleoProjectClasspathEntry(inputDirectory, outputDirectory); dependingClasspathEntries.add(classpathEntry); } aDependingProject.addClasspathEntries(dependingClasspathEntries); aProject.addProjectDependencies(Sets.newHashSet(aDependingProject)); } } log.info("Adding jar dependencies..."); List<String> jars = this.acceleoProject.getJars(); if (jars != null) { Set<URI> newDependencies = new LinkedHashSet<URI>(); for (String jar : jars) { log.info("Resolving jar: '" + jar + "'..."); File jarFile = new File(jar); if (jarFile.isFile()) { URI uri = URI.createFileURI(jar); newDependencies.add(uri); log.info("Found jar for '" + jar + "' on the filesystem: '" + jarFile.getAbsolutePath() + "'."); } else { StringTokenizer tok = new StringTokenizer(jar, ":"); String groupdId = null; String artifactId = null; String version = null; int c = 0; while (tok.hasMoreTokens()) { String nextToken = tok.nextToken(); if (c == 0) { groupdId = nextToken; } else if (c == 1) { artifactId = nextToken; } else if (c == 2) { version = nextToken; } c++; } Set<?> artifacts = this.project.getArtifacts(); for (Object object : artifacts) { if (object instanceof Artifact) { Artifact artifact = (Artifact) object; if (groupdId != null && groupdId.equals(artifact.getGroupId()) && artifactId != null && artifactId.equals(artifact.getArtifactId())) { if (version != null && version.equals(artifact.getVersion())) { File artifactFile = artifact.getFile(); if (artifactFile != null && artifactFile.exists()) { URI uri = URI.createFileURI(artifactFile.getAbsolutePath()); newDependencies.add(uri); log.info("Found jar for '" + jar + "' on the filesystem: '" + uri.toString() + "'."); } } else if (version == null) { File artifactFile = artifact.getFile(); if (artifactFile != null && artifactFile.exists()) { URI uri = URI.createFileURI(artifactFile.getAbsolutePath()); newDependencies.add(uri); log.info("Found jar for '" + jar + "' on the filesystem: '" + uri.toString() + "'."); } } } } } List<?> mavenDependencies = this.project.getDependencies(); for (Object object : mavenDependencies) { if (object instanceof Dependency) { Dependency dependency = (Dependency) object; if (groupdId != null && groupdId.equals(dependency.getGroupId()) && artifactId != null && artifactId.equals(dependency.getArtifactId())) { if (version != null && version.equals(dependency.getVersion())) { String systemPath = dependency.getSystemPath(); if (systemPath != null && new File(systemPath).exists()) { URI uri = URI.createFileURI(systemPath); newDependencies.add(uri); log.info("Found jar for '" + jar + "' on the filesystem: '" + uri.toString() + "'."); } } else if (version == null) { String systemPath = dependency.getSystemPath(); if (systemPath != null && new File(systemPath).exists()) { URI uri = URI.createFileURI(systemPath); newDependencies.add(uri); log.info("Found jar for '" + jar + "' on the filesystem: '" + uri.toString() + "'."); } } } } } } } aProject.addDependencies(newDependencies); } log.info("Starting parsing..."); AcceleoParser parser = new AcceleoParser(aProject, this.useBinaryResources, this.usePlatformResourcePath); AcceleoParserListener listener = new AcceleoParserListener(); parser.addListeners(listener); // Load and plug the uri resolver if (this.uriHandler != null && newLoader != null) { try { Class<?> forName = Class.forName(this.uriHandler, true, newLoader); Object newInstance = forName.newInstance(); if (newInstance instanceof IAcceleoParserURIHandler) { IAcceleoParserURIHandler resolver = (IAcceleoParserURIHandler) newInstance; parser.setURIHandler(resolver); } } catch (ClassNotFoundException e) { log.error(e); } catch (InstantiationException e) { log.error(e); } catch (IllegalAccessException e) { log.error(e); } } Set<File> builtFiles = parser.buildAll(new BasicMonitor()); boolean errorFound = false; for (File builtFile : builtFiles) { Collection<AcceleoParserProblem> problems = parser.getProblems(builtFile); Collection<AcceleoParserWarning> warnings = parser.getWarnings(builtFile); if (problems.size() > 0) { log.info("Errors for file '" + builtFile.getName() + "': " + problems); errorFound = true; } if (warnings.size() > 0) { log.info("Warnings for file '" + builtFile.getName() + "': " + warnings); } } if (errorFound && failOnError) { throw new MojoExecutionException("Errors have been found during the build of the generator"); } // Removing everything AcceleoPackageRegistry.INSTANCE.clear(); log.info("Build completed."); }