List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:com.opoopress.maven.plugins.plugin.AbstractDeployMojo.java
License:Apache License
/** * @param wagon/* w w w . ja v a 2 s. c om*/ * @param log */ private static void configureLog(Wagon wagon, Log log) { try { Method method = wagon.getClass().getMethod("setLog", Log.class); method.invoke(wagon, log); log.info("Set log for wagon: " + wagon); } catch (Exception e) { log.debug("Wagon does not supports setLog() method."); } }
From source file:com.photon.maven.plugins.android.phase09package.ApkBuilder.java
License:Apache License
/** * Before being able to use the ApkBuilder, an initialization is required. * * @param log// ww w. j a va 2 s .c o m * the Mojo Logger * @param sdkLibs * the File pointing on {@code sdklib.jar} * @throws MojoExecutionException * if the ApkBuilder class cannot be loaded */ @SuppressWarnings("unchecked") public static void initialize(Log log, File sdkLibs) throws MojoExecutionException { if (apkBuilderClass != null) { // Already initialized return; } ApkBuilder.log = log; // Loads the ApkBuilder class try { URLClassLoader child = new URLClassLoader(new URL[] { sdkLibs.toURI().toURL() }, ApkBuilder.class.getClassLoader()); apkBuilderClass = child.loadClass("com.android.sdklib.build.ApkBuilder"); } catch (MalformedURLException e) { // This one cannot happen. throw new RuntimeException("Cannot create a correct URL from file " + sdkLibs.getAbsolutePath()); } catch (ClassNotFoundException e) { log.error(e); throw new MojoExecutionException("Cannot load 'com.android.sdklib.build.ApkBuilder'"); } log.debug("ApkBuilder loaded " + apkBuilderClass); // In order to improve performence and to check that all methods are available // we cache used methods. try { apkBuilderConstructor = apkBuilderClass.getConstructor( new Class[] { File.class, File.class, File.class, String.class, PrintStream.class }); setDebugMethod = apkBuilderClass.getMethod("setDebugMode", new Class[] { Boolean.TYPE }); addResourcesFromJarMethod = apkBuilderClass.getMethod("addResourcesFromJar", new Class[] { File.class }); //The addNativeLibraries signature changed for api 14 Method[] builderMethods = apkBuilderClass.getMethods(); for (Method method : builderMethods) { if ("addNativeLibraries".equals(method.getName())) { Class<?>[] parameterTypes = method.getParameterTypes(); //The old method (pre v14) took a second string parameter. if (parameterTypes.length == 2) { if (parameterTypes[0] == File.class && parameterTypes[1] == String.class) { addNativeLibrariesMethod = method; break; } } else if (parameterTypes.length == 1 && parameterTypes[0] == File.class) { addNativeLibrariesMethod = method; break; } } } addSourceFolderMethod = apkBuilderClass.getMethod("addSourceFolder", new Class[] { File.class }); sealApkMethod = apkBuilderClass.getMethod("sealApk", new Class[0]); getDebugKeyStoreMethod = apkBuilderClass.getMethod("getDebugKeystore", new Class[0]); } catch (Exception e) { log.error("Cannot find required method", e); throw new MojoExecutionException("Cannot find the required method", e); } }
From source file:com.puresoltechnologies.maven.plugins.license.AbstractValidationMojo.java
/** * Loads the artifact recursively.//from ww w.j a v a2 s . c om * * @param artifact * @param recursive * specified whether all dependencies should be loaded * recursively. * @param skipTestScope * specified whether to skip test scoped artifacts or not. * @return A {@link DependencyTree} object is returned. * @throws MojoExecutionException * is thrown if anything unexpected goes wrong. */ private DependencyTree loadArtifacts(int depth, DependencyTree parentDependencyTree, Artifact artifact, boolean recursive, boolean skipTestScope, boolean skipProvidedScope, boolean skipOptionals) throws MojoExecutionException { Log log = getLog(); MavenProject parentArtifactProject; try { parentArtifactProject = mavenProjectBuilder.buildFromRepository(artifact, remoteArtifactRepositories, localRepository); } catch (ProjectBuildingException e) { log.warn("Could not load artifacts recursively. For artifact '" + ArtifactUtilities.toString(artifact) + "' the project creation failed.", e); return null; } @SuppressWarnings("unchecked") List<Dependency> dependencies = parentArtifactProject.getDependencies(); @SuppressWarnings("unchecked") List<License> licenses = parentArtifactProject.getLicenses(); DependencyTree dependencyTree = new DependencyTree(artifact, licenses); if (parentDependencyTree != null) { parentDependencyTree.addDependency(dependencyTree); } if ((dependencies != null) && ((recursive) || (artifact == mavenProject.getArtifact()))) { for (Dependency dependency : dependencies) { StringBuffer buffer = new StringBuffer(); if (log.isDebugEnabled()) { for (int i = 0; i < depth; i++) { buffer.append(" "); } buffer.append("\\-> "); log.debug(buffer.toString() + ArtifactUtilities.toString(dependency)); } if (skipTestScope && Artifact.SCOPE_TEST.equals(dependency.getScope())) { if (log.isDebugEnabled()) { log.debug(buffer.toString() + " >> test scope is skipped"); } continue; } if (skipProvidedScope && Artifact.SCOPE_PROVIDED.equals(dependency.getScope())) { if (log.isDebugEnabled()) { log.debug(buffer.toString() + " >> provided scope is skipped"); } continue; } if (skipOptionals && dependency.isOptional()) { if (log.isDebugEnabled()) { log.debug(buffer.toString() + " >> optional is skipped"); } continue; } if (hasCycle(dependencyTree, dependency)) { if (log.isDebugEnabled()) { log.debug(buffer.toString() + " >> cylce found and needs to be skipped"); } continue; } Artifact dependencyArtifact = DependencyUtilities.buildArtifact(artifact, dependency); loadArtifacts(depth + 1, dependencyTree, dependencyArtifact, recursive, skipTestScope, skipProvidedScope, skipOptionals); } } return dependencyTree; }
From source file:com.puresoltechnologies.maven.plugins.license.internal.IOUtilities.java
/** * This method checks a directory for presence. If it is not existing, it * will be created./*from w w w. jav a2s . c o m*/ * * @param log * is the {@link Log} to write to. * @param directory * is the directory to be checked and created if needed. * @throws MojoExecutionException * is thrown if the directory is not present and could not be * created. */ public static void createDirectoryIfNotPresent(Log log, File directory) throws MojoExecutionException { if (!directory.exists()) { log.debug("Directory '" + directory + "' is not present. Creating it..."); if (!directory.mkdirs()) { throw new MojoExecutionException("Could not create directory '" + directory + "'."); } } else if (!directory.isDirectory()) { throw new MojoExecutionException("'" + directory + "' is not a directory, but is supposed to be."); } }
From source file:com.puresoltechnologies.maven.plugins.license.internal.IOUtilities.java
/** * This method checks a file for presence. If it is not existing, it will be * created.//w ww.j a v a 2 s . c om * * @param log * is the {@link Log} to write to. * @param file * is the directory to be checked and created if needed. * @throws MojoExecutionException * is thrown if the directory is not present and could not be * created. */ public static void createFileIfNotPresent(Log log, File file) throws MojoExecutionException { try { if (!file.exists()) { log.debug("file '" + file + "' is not present. Creating it..."); if (!file.createNewFile()) { throw new MojoExecutionException("Could not create directory '" + file + "'."); } } else if (!file.isFile()) { throw new MojoExecutionException("'" + file + "' is not a file, but is supposed to be."); } } catch (IOException e) { throw new MojoExecutionException("Could not create a new file '" + file + "'.", e); } }
From source file:com.puresoltechnologies.maven.plugins.license.internal.IOUtilities.java
/** * This method checks the presence of a file. If it is present, it is * deleted./*from w w w .j a v a2 s .c o m*/ * * @param log * is the Maven logger {@link Log}. * @param file * is the files to be deleted if present. * @throws MojoExecutionException * is thrown in cases of IO issues. */ public static void deleteFileIfPresent(Log log, File file) throws MojoExecutionException { if (file.exists()) { log.debug("Results file exists. Delete it to remove obsolete results."); if (!file.delete()) { throw new MojoExecutionException("Could not delete license results file '" + file + "'."); } } }
From source file:com.pushtechnology.mvndar.AddDependenciesTask.java
License:Apache License
@Override public void perform(final DARMojoContext context) throws IOException { // This only gets the direct dependencies. See // https://github.com/pushtechnology/mvndar/issues/1 @SuppressWarnings("unchecked") final Set<Artifact> dependencies = context.getProject().getDependencyArtifacts(); final Log log = context.getLog(); for (final Artifact a : dependencies) { if (a.isOptional()) { log.debug("Ignoring optional dependency: " + a); continue; }/* w w w . j av a 2s .c om*/ if (!context.getAcceptedDependencyScopes().contains(a.getScope())) { log.debug("Ignoring dependency (scope): " + a); continue; } if ("com.pushtechnology".equals(a.getGroupId()) && "diffusion-api".equals(a.getArtifactId())) { continue; } if (context.getExtTypes().contains(a.getType())) { if (a.getFile() == null) { // Happens for relocated artifacts, e.g. // org.apache.commons:commons-io:jar:1.3.2 log.warn("Failed to locate dependency " + a + ", skipping"); continue; } final File f = a.getFile().getCanonicalFile(); final File target = FileUtils.getFile(context.getPrefixDirectoryName(), context.getExtDirectoryName(), f.getName()); context.getArchiver().addFile(f, target.toString()); log.debug("Dependency " + a + " has been copied to " + target); } else { log.debug("Ignoring dependency: " + a); } } }
From source file:com.pushtechnology.mvndar.CreateManifestTask.java
License:Apache License
@Override public void perform(final DARMojoContext context) throws IOException { final Log log = context.getLog(); final MavenArchiveConfiguration archiveConfiguration = context.getArchiveConfiguration(); archiveConfiguration.getManifestEntries().put("Diffusion-Version", context.getMinimumDiffusionVersion()); log.debug("Manifest entries: " + archiveConfiguration.getManifestEntries()); }
From source file:com.qpark.maven.plugin.collectschemas.CondenseServiceSchemasMojo.java
License:Open Source License
protected static void condense(final XsdsUtil xsds, final String serviceId, final File baseDirectory, final File outputDirectory, final Log log) throws IOException { List<String> serviceIds = ServiceIdRegistry.splitServiceIds(serviceId); if (Objects.nonNull(serviceIds) && serviceIds.size() > 0) { xsds.getXsdContainerMap().values().stream().forEach(xc -> log .debug(String.format("Contains namespaces: %s %s", xc.getTargetNamespace(), xc.getFile()))); TreeSet<String> importedNamespaces = new TreeSet<String>(); xsds.getServiceIdRegistry().getAllServiceIds().stream().filter(si -> serviceIds.contains(si)) .map(si -> xsds.getServiceIdRegistry().getServiceIdEntry(si)) .map(sie -> sie.getTargetNamespace()).filter(tn -> Objects.nonNull(tn)) .map(tn -> xsds.getXsdContainer(tn)).filter(xc -> Objects.nonNull(xc)).forEach(xc -> { addImportedNamespaces(xsds, xc, importedNamespaces); });//from ww w. ja va2 s . c o m if (Objects.nonNull(outputDirectory) && !baseDirectory.equals(outputDirectory)) { log.info(String.format("Copy namespaces: %s", importedNamespaces)); xsds.getXsdContainerMap().values().stream() .filter(xc -> importedNamespaces.contains(xc.getTargetNamespace())).forEach(xc -> { try { copyFile(baseDirectory, outputDirectory, xc.getFile(), log); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }); } else { log.info(String.format("Keep namespaces: %s", importedNamespaces)); xsds.getXsdContainerMap().values().stream() .filter(xc -> !importedNamespaces.contains(xc.getTargetNamespace())).forEach(xc -> { if (xc.getFile().delete()) { log.info(String.format("Delete file %s", xc.getFile())); } else { log.info(String.format("Could not delete file %s", xc.getFile())); } }); } } }
From source file:com.qq.tars.maven.util.ArchiveEntryUtils.java
License:Open Source License
public static void chmod(final File file, final int mode, final Log logger, boolean useJvmChmod) throws ArchiverException { if (!Os.isFamily(Os.FAMILY_UNIX)) { return;/*from w w w. j av a 2s . c om*/ } final String m = Integer.toOctalString(mode & 0xfff); if (useJvmChmod && !jvmFilePermAvailable) { logger.info("chmod it's not possible where your current jvm"); useJvmChmod = false; } if (useJvmChmod && jvmFilePermAvailable) { applyPermissionsWithJvm(file, m, logger); return; } try { final Commandline commandline = new Commandline(); commandline.setWorkingDirectory(file.getParentFile().getAbsolutePath()); if (logger.isDebugEnabled()) { logger.debug(file + ": mode " + Integer.toOctalString(mode) + ", chmod " + m); } commandline.setExecutable("chmod"); commandline.createArg().setValue(m); final String path = file.getAbsolutePath(); commandline.createArg().setValue(path); final CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); final int exitCode = CommandLineUtils.executeCommandLine(commandline, stderr, stdout); if (exitCode != 0) { logger.warn("-------------------------------"); logger.warn("Standard error:"); logger.warn("-------------------------------"); logger.warn(stderr.getOutput()); logger.warn("-------------------------------"); logger.warn("Standard output:"); logger.warn("-------------------------------"); logger.warn(stdout.getOutput()); logger.warn("-------------------------------"); throw new ArchiverException("chmod exit code was: " + exitCode); } } catch (final CommandLineException e) { throw new ArchiverException("Error while executing chmod.", e); } }