List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.reader.ReadWorkspaceLocations.java
License:Apache License
/** * Scan the eclipse workspace and create a array with {@link IdeDependency} for all found artifacts. * * @param workspaceLocation the location of the eclipse workspace. * @param logger the logger to report errors and debug info. *//* w w w . j av a 2 s .c om*/ private void readWorkspace(WorkspaceConfiguration workspaceConfiguration, Log logger) { ArrayList dependencies = new ArrayList(); if (workspaceConfiguration.getWorkspaceDirectory() != null) { File workspace = new File(workspaceConfiguration.getWorkspaceDirectory(), ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RESOURCES_PROJECTS); File[] directories = workspace.listFiles(); for (int index = 0; directories != null && index < directories.length; index++) { File project = directories[index]; if (project.isDirectory()) { try { File projectLocation = getProjectLocation(workspaceConfiguration.getWorkspaceDirectory(), project); if (projectLocation != null) { logger.debug("read workpsace project " + projectLocation); IdeDependency ideDependency = readArtefact(projectLocation, logger); if (ideDependency != null) { dependencies.add(ideDependency); } } } catch (Exception e) { logger.warn("could not read workspace project:" + project, e); } } } } logger.debug(dependencies.size() + " from workspace " + workspaceConfiguration.getWorkspaceDirectory()); workspaceConfiguration.setWorkspaceArtefacts( (IdeDependency[]) dependencies.toArray(new IdeDependency[dependencies.size()])); }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.writers.EclipseManifestWriter.java
License:Apache License
/** * make room for a Manifest file. use a generated resource for JARS and for WARS use the manifest in the * webapp/META-INF directory./* ww w. j a va 2s .c o m*/ * * @throws MojoExecutionException */ public static void addManifestResource(Log log, EclipseWriterConfig config) throws MojoExecutionException { AbstractEclipseManifestWriter manifestWriter = new EclipseManifestWriter(); manifestWriter.init(log, config); String packaging = config.getProject().getPackaging(); String manifestDirectory = manifestWriter.getMetaInfBaseDirectory(config.getProject()); if (!Constants.PROJECT_PACKAGING_EAR.equals(packaging) && !Constants.PROJECT_PACKAGING_WAR.equals(packaging) && manifestDirectory == null) { String generatedResourceDir = config.getProject().getBasedir().getAbsolutePath() + File.separatorChar + EclipseManifestWriter.GENERATED_RESOURCE_DIRNAME; manifestDirectory = generatedResourceDir + File.separatorChar + "META-INF"; try { new File(manifestDirectory).mkdirs(); File manifestFile = new File(manifestDirectory + File.separatorChar + "MANIFEST.MF"); if (manifestFile.exists()) { manifestFile.delete(); } manifestFile.createNewFile(); } catch (IOException e) { log.error(Messages.getString("EclipsePlugin.cantwritetofile", new Object[] { manifestDirectory + File.separatorChar + "META-INF" + File.separatorChar + "MANIFEST.MF" })); } log.debug("Adding " + EclipseManifestWriter.GENERATED_RESOURCE_DIRNAME + " to eclipse sources "); EclipseSourceDir[] sourceDirs = config.getSourceDirs(); EclipseSourceDir[] newSourceDirs = new EclipseSourceDir[sourceDirs.length + 1]; System.arraycopy(sourceDirs, 0, newSourceDirs, 0, sourceDirs.length); newSourceDirs[sourceDirs.length] = new EclipseSourceDir( EclipseManifestWriter.GENERATED_RESOURCE_DIRNAME, null, true, false, null, null, false); config.setSourceDirs(newSourceDirs); } if (Constants.PROJECT_PACKAGING_WAR.equals(packaging)) { new File(getWebContentBaseDirectory(config) + File.separatorChar + "META-INF").mkdirs(); } // special case must be done first because it can add stuff to the // classpath that will be // written by the superclass manifestWriter.write(); }
From source file:com.alibaba.citrus.maven.eclipse.base.ide.IdeUtils.java
License:Apache License
/** * Delete a file, handling log messages and exceptions * * @param f File to be deleted/* www. j a va 2 s .c o m*/ * @throws MojoExecutionException only if a file exists and can't be deleted */ public static void delete(File f, Log log) throws MojoExecutionException { if (f.isDirectory()) { log.info(Messages.getString("EclipseCleanMojo.deletingDirectory", f.getName())); //$NON-NLS-1$ } else { log.info(Messages.getString("EclipseCleanMojo.deletingFile", f.getName())); //$NON-NLS-1$ } if (f.exists()) { if (!f.delete()) { try { FileUtils.forceDelete(f); } catch (IOException e) { throw new MojoExecutionException(Messages.getString("EclipseCleanMojo.failedtodelete", //$NON-NLS-1$ new Object[] { f.getName(), f.getAbsolutePath() })); } } } else { log.debug(Messages.getString("EclipseCleanMojo.nofilefound", f.getName())); //$NON-NLS-1$ } }
From source file:com.ariht.maven.plugins.config.ConfigGenerationMojo.java
License:Apache License
/** * Clear target io and create new scripts and config io. *//*from w w w. j a v a 2 s . c o m*/ public void execute() throws MojoExecutionException, MojoFailureException { final Log log = getLog(); Preconditions.checkNotNull(log); final ConfigGeneratorParameters parameters = new ConfigGeneratorParametersBuilder(log) .withEncoding(encoding).withTemplatesBasePath(templatesBasePath) .withFiltersBasePath(filtersBasePath).withExternalFilterBasePaths(externalFilterBasePaths) .withOutputBasePath(outputBasePath).isWithLogOutput(logOutput) .withTemplatesToIgnore(templatesToIgnore).withFiltersToIgnore(filtersToIgnore) .withFilterSourcePropertyName(filterSourcePropertyName).withPropertyPrefix(propertyPrefix) .withPropertySuffix(propertySuffix).isWithFailOnMissingProperty(failOnMissingProperty).build(); if (log.isDebugEnabled()) { log.debug("configGeneratorParameters: [" + parameters.toString() + "]"); } final ConfigGeneratorImpl configGenerator = new ConfigGeneratorImpl(log, parameters); if (log.isDebugEnabled()) { } configGenerator.processFiltersIntoTemplates(); }
From source file:com.ariht.maven.plugins.config.io.DirectoryDeleter.java
License:Apache License
/** * Clear contents of config generation build target/output io ready for new directory. *//* www.java 2s . c o m*/ public void clearTargetDirectory(final String outputBasePath, final Log logger) throws MojoFailureException { final File outputDir = new File(outputBasePath); if (outputDir.exists()) { logger.debug("Deleting : " + outputDir); try { FileUtils.forceDelete(outputDir); } catch (IOException e) { logger.error("Error while clearing config generation output io: [" + outputDir + "], error was: " + String.valueOf(e.getMessage())); throw new MojoFailureException(e.getMessage(), e); } } }
From source file:com.atlassian.maven.plugin.clover.internal.AbstractCloverMojo.java
License:Apache License
/** * Registers the license file for Clover runtime by setting the <code>clover.license.path</code> system property. * If the user has configured the <code>licenseLocation</code> parameter the plugin tries to resolve it first as a * resource, then as a URL, and then as a file location on the filesystem. * * Note: We're defining this method as static because it is also required in the report mojo and reporting mojos * and main mojos cannot share anything right now. See http://jira.codehaus.org/browse/MNG-1886. * * @param project maven project/*w w w . j a v a 2 s. c om*/ * @param resourceManager resource manager * @param licenseLocation path to license file * @param logger logger * @param classloader class loader * @param licenseCert license key * @throws MojoExecutionException when the license file cannot be found */ public static void registerLicenseFile(final MavenProject project, final ResourceManager resourceManager, final String licenseLocation, final Log logger, final ClassLoader classloader, final String licenseCert) throws MojoExecutionException { if (licenseCert != null) { logger.debug("Full license supplied. Length: '" + licenseCert.length() + "'. License location: '" + licenseLocation + "' will be ignored."); System.setProperty(CloverNames.PROP_LICENSE_CERT, licenseCert); return; } if (licenseLocation != null) { logger.debug("Using licenseLocation '" + licenseLocation + "'"); final File licenseFile = getResourceAsFile(project, resourceManager, licenseLocation, logger, classloader); logger.debug("Using license file [" + licenseFile.getPath() + "]"); System.setProperty(CloverNames.PROP_LICENSE_PATH, licenseFile.getPath()); } else { logger.info("No 'maven.clover.licenseLocation' configured. Using default license."); } }
From source file:com.atlassian.maven.plugin.clover.internal.AbstractCloverMojo.java
License:Apache License
public static File getResourceAsFile(final MavenProject project, final ResourceManager resourceManager, final String resourceLocation, final Log logger, final ClassLoader classloader) throws MojoExecutionException { logger.debug("Getting resource: '" + resourceLocation + "'"); resourceManager.addSearchPath("url", ""); resourceManager.addSearchPath(FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath()); final ClassLoader origLoader = Thread.currentThread().getContextClassLoader(); try {/* w w w. ja v a 2 s . c o m*/ Thread.currentThread().setContextClassLoader(classloader); try { logger.debug("Attempting to load resource from [" + resourceLocation + "] ..."); final File outputFile = File.createTempFile("mvn", "resource"); outputFile.deleteOnExit(); return resourceManager.getResourceAsFile(resourceLocation, outputFile.getPath()); } catch (Exception e) { throw new MojoExecutionException("Failed to load resource as file [" + resourceLocation + "]", e); } } finally { Thread.currentThread().setContextClassLoader(origLoader); } }
From source file:com.betfair.cougar.codegen.IDLReader.java
License:Apache License
public void init(Document iddDoc, Document extensionDoc, final String service, String packageName, final String basedir, final String genSrcDir, final Log log, final String outputDir, boolean client, boolean server) throws Exception { try {//from w w w. j a v a 2s . c om output = new File(basedir, genSrcDir); if (outputDir != null) { iDDOutputDir = new File(basedir + "/" + outputDir); if (!iDDOutputDir.exists()) { if (!iDDOutputDir.mkdirs()) { throw new IllegalArgumentException( "IDD Output Directory " + iDDOutputDir + " could not be created"); } } if (!iDDOutputDir.isDirectory() || (!iDDOutputDir.canWrite())) { throw new IllegalArgumentException("IDD Output Directory " + iDDOutputDir + " is not a directory or cannot be written to."); } } config = new Configuration(); config.setClassForTemplateLoading(IDLReader.class, "/templates"); config.setStrictSyntaxMode(true); this.log = log; this.packageName = packageName; this.service = service; this.client = client; this.server = server || !client; // server must be true if client if false. dataModel = NodeModel.wrap(iddDoc.cloneNode(true)); if (extensionDoc != null) { NodeModel extensionModel = NodeModel.wrap(extensionDoc); mergeExtensionsIntoDocument(getRootNode(dataModel), getRootNode(extensionModel)); removeUndefinedOperations(getRootNode(dataModel), getRootNode(extensionModel)); } if (log.isDebugEnabled()) { log.debug(serialize()); } } catch (final Exception e) { log.error("Failed to initialise FTL", e); throw e; } }
From source file:com.betfair.cougar.codegen.resolver.DefaultSchemaCatalogSource.java
License:Apache License
@Override public File getCatalog(File destDir, Log log) { // schemas//from w ww . j a v a2s. c o m for (String s : getSchemas()) { log.debug("Copying " + s + " to " + destDir); FileUtil.resourceToFile(s, new File(destDir, s), getClass()); } // catalog (which works using relative links) File catalogFile = new File(destDir, getCatalogFileName()); log.debug("Copying " + getCatalogFileName() + " to " + destDir); FileUtil.resourceToFile(getCatalogFileName(), catalogFile, getClass()); return catalogFile; }
From source file:com.betfair.cougar.transformations.Main.java
License:Apache License
/** * @param args/*from w w w . ja va 2 s . co m*/ */ public static void main(String[] args) throws Exception { Transformations transform = new CougarTransformations(); IDLReader reader = new IDLReader(); Log log = new SystemStreamLog(); File idd = new File("src\\main\\resources\\BaselineService.xml"); InterceptingResolver resolver = new InterceptingResolver(); Document iddDoc = XmlUtil.parse(idd, resolver); File ext = new File("src\\main\\resources\\BaselineService-Extensions.xml"); Document extDoc = null; if (ext.exists()) { extDoc = XmlUtil.parse(ext, resolver); } reader.init(iddDoc, extDoc, "BaselineService", "com.betfair.baseline", ".", "/target/generated-sources", log, new Service().getOutputDir(), true, true); // First let's mangle the document if need be. if (transform.getManglers() != null) { log.debug("mangling IDL using " + transform.getManglers().size() + " pre validations"); for (DocumentMangler m : transform.getManglers()) { log.debug(m.getName()); reader.mangle(m); } log.debug(reader.serialize()); } for (Validator v : transform.getPreValidations()) { reader.validate(v); } log.debug(reader.serialize()); reader.runMerge(transform.getTransformations()); reader.writeResult(); }