org.apache.maven.plugin.logging.Log#debug ( )源码实例Demo

下面列出了org.apache.maven.plugin.logging.Log#debug ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: botsing   文件: ProcessRunner.java
private static void handleProcessOutput(final Process process, Log logger) {

		Thread reader = new Thread() {
			@Override
			public void run() {
				try {
					BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));

					while (!this.isInterrupted()) {
						String line = in.readLine();
						if (line != null && !line.isEmpty()) {
							logger.info(line);
						}
					}
				} catch (Exception e) {
					logger.debug("Exception while reading spawn process output: " + e.toString());
				}
			}
		};

		reader.start();
		logger.debug("Started thread to read spawn process output");
	}
 
源代码2 项目: extra-enforcer-rules   文件: RequireEncoding.java
protected String getEncoding( String requiredEncoding, File file, Log log )
    throws IOException
{
    FileEncoding fileEncoding = new FileEncoding();
    if ( !fileEncoding.guessFileEncoding( Files.readAllBytes( file.toPath() ) ) )
    {
        return null;
    }

    if ( log.isDebugEnabled() )
    {
        log.debug( String.format( "%s: (%s) %s; charset=%s", file, fileEncoding.getCode(), fileEncoding.getType(), fileEncoding.getCodeMime() ) );
    }

    return fileEncoding.getCodeMime().toUpperCase();
}
 
源代码3 项目: cougar   文件: DefaultSchemaCatalogSource.java
@Override
public File getCatalog(File destDir, Log log) {

    // schemas
    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;
}
 
源代码4 项目: versions-maven-plugin   文件: PomHelper.java
/**
 * Outputs a debug message with a list of modules.
 *
 * @param logger The logger to log to.
 * @param message The message to display.
 * @param modules The modules to append to the message.
 */
public static void debugModules( Log logger, String message, Collection modules )
{
    Iterator i;
    if ( logger.isDebugEnabled() )
    {
        logger.debug( message );
        if ( modules.isEmpty() )
        {
            logger.debug( "None." );
        }
        else
        {
            i = modules.iterator();
            while ( i.hasNext() )
            {
                logger.debug( "  " + i.next() );
            }
        }

    }
}
 
源代码5 项目: versions-maven-plugin   文件: PomHelper.java
/**
 * Returns a set of all child modules for a project, including any defined in profiles (ignoring profile
 * activation).
 *
 * @param model The project model.
 * @param logger The logger to use.
 * @return the set of all child modules of the project.
 */
public static Set<String> getAllChildModules( Model model, Log logger )
{
    logger.debug( "Finding child modules..." );
    Set<String> childModules = new TreeSet<String>();
    childModules.addAll( model.getModules() );
    for ( Profile profile : model.getProfiles() )
    {
        childModules.addAll( profile.getModules() );
    }
    debugModules( logger, "Child modules:", childModules );
    return childModules;
}
 
源代码6 项目: pitest   文件: ReportSourceLocator.java
private File executeLocator(File reportsDirectory, Log log) {
  File[] subdirectories = reportsDirectory
      .listFiles(TIMESTAMPED_REPORTS_FILE_FILTER);
  File latest = reportsDirectory;

  log.debug("ReportSourceLocator starting search in directory ["
      + reportsDirectory.getAbsolutePath() + "]");

  if (subdirectories != null) {
    LastModifiedFileComparator c = new LastModifiedFileComparator();

    for (File f : subdirectories) {
      log.debug("comparing directory [" + f.getAbsolutePath()
          + "] with the current latest directory of ["
          + latest.getAbsolutePath() + "]");
      if (c.compare(latest, f) < 0) {
        latest = f;
        log.debug("directory [" + f.getAbsolutePath() + "] is now the latest");
      }
    }
  } else {
    throw new PitError("could not list files in directory ["
        + reportsDirectory.getAbsolutePath()
        + "] because of an unknown I/O error");
  }

  log.debug("ReportSourceLocator determined directory ["
      + latest.getAbsolutePath()
      + "] is the directory containing the latest pit reports");
  return latest;
}
 
private void logInterfacesImplemented(Log log, JavaClass nextClass) {
    if (log.isDebugEnabled()) {
        final List<JavaClass> implementedInterfaces = getAllInterfacesQdox(nextClass);
        for (JavaClass implemented: implementedInterfaces) {
            log.debug("Interface implemented: " + implemented);
        }
    }
}
 
源代码8 项目: neoscada   文件: DefaultPomHelper.java
@Override
public Set<MavenProject> expandProjects ( final Collection<MavenProject> projects, final Log log, final MavenSession session )
{
    try
    {
        final Set<MavenProject> result = new HashSet<MavenProject> ();

        final Queue<MavenProject> queue = new LinkedList<MavenProject> ( projects );
        while ( !queue.isEmpty () )
        {
            final MavenProject project = queue.poll ();
            log.debug ( "Checking project: " + project );
            if ( project.getFile () == null )
            {
                log.info ( "Skipping non-local project: " + project );
                continue;
            }
            if ( !result.add ( project ) )
            {
                // if the project was already in our result, there is no need to process twice
                continue;
            }
            // add all children to the queue
            queue.addAll ( loadChildren ( project, log, session ) );
            if ( hasLocalParent ( project ) )
            {
                // if we have a parent, add the parent as well
                queue.add ( project.getParent () );
            }
        }
        return result;
    }
    catch ( final Exception e )
    {
        throw new RuntimeException ( e );
    }
}
 
public List<Ec2Instance> getInstancesForAutoScalingGroup(Log log, AutoScalingGroup autoScalingGroup) throws MojoFailureException {
    log.info("retrieving list of instanceId's for auto scaling group with id : " + activeConfiguration.getAutoScalingGroupId());

    activeConfiguration.getHosts().clear();

    log.debug("describing instances in auto scaling group");

    if (autoScalingGroup.getInstances().isEmpty()) {
        return new ArrayList<>();
    }

    Map<String, Instance> instanceMap = autoScalingGroup.getInstances().stream().collect(Collectors.toMap(Instance::getInstanceId, Function.identity()));

    try {
        DescribeInstancesResult instancesResult = awsEc2Client.describeInstances(new DescribeInstancesRequest().withInstanceIds(autoScalingGroup.getInstances().stream().map(Instance::getInstanceId).collect(Collectors.toList())));
        List<Ec2Instance> ec2Instances = instancesResult.getReservations().stream().flatMap(r -> r.getInstances().stream()).map(this::toEc2Instance).collect(Collectors.toList());
        log.debug("describing elb status");
        autoScalingGroup.getLoadBalancerNames().forEach(elb -> this.updateInstancesStateOnLoadBalancer(elb, ec2Instances));
        ec2Instances.forEach(i -> i.updateAsState(AwsState.map(instanceMap.get(i.getInstanceId()).getLifecycleState())));
        ec2Instances.sort((o1, o2) -> {

            int sComp = o1.getAsState().compareTo(o2.getAsState());

            if (sComp != 0) {
                return sComp;
            } else {
                return o1.getElbState().compareTo(o2.getElbState());
            }
        });
        if (activeConfiguration.isIgnoreInStandby()) {
            return ec2Instances.stream().filter(i -> i.getAsState() != AwsState.STANDBY).collect(Collectors.toList());
        }
        return ec2Instances;
    } catch (AmazonClientException e) {
        log.error(e.getMessage(), e);
        throw new MojoFailureException(e.getMessage());
    }

}
 
/**
 * Execute the rule.
 *
 * @param helper the helper
 * @throws EnforcerRuleException the enforcer rule exception
 */
public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException
{
    final Log log = helper.getLog();

    Object propValue = getPropertyValue( helper );
    checkPropValueNotBlank( propValue );

    final MavenProject project = getMavenProject( helper );
    log.debug( getRuleName() + ": checking property '" + property + "' for project " + project );

    final MavenProject parent = findDefiningParent( project );

    // fail fast if the defining parent could not be found due to a bug in the rule
    if ( parent == null )
    {
        throw new IllegalStateException( "Failed to find parent POM which defines the current rule" );
    }

    if ( project.equals( parent ) )
    {
        log.debug( getRuleName() + ": skip for property '" + property + "' as " + project + " defines rule." );
    }
    else
    {
        log.debug( "Check configuration defined in " + parent );
        if ( regex == null )
        {
            checkAgainstParentValue( project, parent, helper, propValue );
        }
        else
        {
            checkAgainstRegex( propValue );
        }
    }
}
 
源代码11 项目: vertx-maven-plugin   文件: ServiceUtils.java
public static Set<Artifact> filterArtifacts(Set<Artifact> artifacts, List<String> includes,
                                            List<String> excludes,
                                            boolean actTransitively, Log logger,
                                            ArtifactFilter... additionalFilters) {

    final AndArtifactFilter filter = new AndArtifactFilter();

    if (additionalFilters != null && additionalFilters.length > 0) {
        for (final ArtifactFilter additionalFilter : additionalFilters) {
            if (additionalFilter != null) {
                filter.add(additionalFilter);
            }
        }
    }

    if (!includes.isEmpty()) {
        final ArtifactFilter includeFilter = new PatternIncludesArtifactFilter(includes, actTransitively);
        filter.add(includeFilter);
    }

    if (!excludes.isEmpty()) {
        final ArtifactFilter excludeFilter = new PatternExcludesArtifactFilter(excludes, actTransitively);
        filter.add(excludeFilter);
    }

    Set<Artifact> copy = new LinkedHashSet<>(artifacts);
    for (final Iterator<Artifact> it = copy.iterator(); it.hasNext(); ) {

        final Artifact artifact = it.next();

        if (!filter.include(artifact)) {
            it.remove();
            if (logger.isDebugEnabled()) {
                logger.debug(artifact.getId() + " was removed by one or more filters.");
            }
        }
    }

    return copy;
}
 
源代码12 项目: opoopress   文件: AbstractDeployMojo.java
/**
 * @param wagon
 * @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.");
    }
}
 
源代码13 项目: versions-maven-plugin   文件: PomHelper.java
/**
 * 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.
 */
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 );
}
 
源代码14 项目: ci.maven   文件: SpringBootUtil.java
/**
 * Read the value of the classifier configuration parameter from the
 * spring-boot-maven-plugin
 * 
 * @param project
 * @param log
 * @return the value if it was found, null otherwise
 */
public static String getSpringBootMavenPluginClassifier(MavenProject project, Log log) {
    String classifier = null;
    try {
        classifier = MavenProjectUtil.getPluginGoalConfigurationString(project,
                "org.springframework.boot:spring-boot-maven-plugin", "repackage", "classifier");
    } catch (PluginScenarioException e) {
        log.debug("No classifier found for spring-boot-maven-plugin");
    }
    return classifier;
}
 
源代码15 项目: mvn-golang   文件: CvsSVN.java
private boolean upToBranch(@Nonnull final Log logger, @Nullable final ProxySettings proxy, @Nullable final String customCommand, @Nonnull final File cvsFolder, @Nonnull final String branchId) {
    logger.debug("upToBranch : " + branchId);
    return checkResult(logger, execute(customCommand, logger, cvsFolder, "switch", "--accept", "theirs-full", "--force", branchId));
}
 
源代码16 项目: TarsJava   文件: ArchiveEntryUtils.java
public static void chmod(final File file, final int mode, final Log logger, boolean useJvmChmod) throws ArchiverException {
    if (!Os.isFamily(Os.FAMILY_UNIX)) {
        return;
    }

    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);
    }

}
 
@Override
public void execute(InstanceConfiguration config)
{
    Log log = config.getClusterConfiguration().getLog();
    
    File pluginsDir = new File(config.getBaseDir(), "plugins");
    try
    {
        log.debug(String.format(
                "Checking if the plugins directory with path: '%s' exists",
                pluginsDir.getCanonicalPath()));
    }
    catch (IOException e)
    {
        throw new ElasticsearchSetupException(
                "Cannot check if the plugins directory exists",
                e);
    }

    if (pluginsDir.exists())
    {
        log.debug("The plugins directory exists; removing all installed plugins");

        if (VersionUtil.isEqualOrGreater_6_4_0(config.getClusterConfiguration().getVersion()))
        {
            FilesystemUtil.setScriptPermission(config, "elasticsearch-cli");
        }
        FilesystemUtil.setScriptPermission(config, "elasticsearch-plugin");

        CommandLine cmd = ProcessUtil.buildCommandLine("bin/elasticsearch-plugin")
                .addArgument("list");
        
        List<String> output = ProcessUtil.executeScript(config, cmd);
        // remove empty entries and trim
        List<String> pluginNames = output.stream()
                .map(String::trim)
                .filter(StringUtils::isNotEmpty)
                .collect(Collectors.toCollection(ArrayList::new));

        for (String pluginName : pluginNames)
        {
            log.info(String.format("Removing plugin '%s'", pluginName));
            
            CommandLine removeCmd = ProcessUtil.buildCommandLine("bin/elasticsearch-plugin")
                    .addArgument("remove")
                    .addArgument(pluginName);
            
            ProcessUtil.executeScript(config, removeCmd, config.getEnvironmentVariables(), null);
        }
    }
    else
    {
        log.debug("The plugins directory does not exist");
    }
}
 
源代码18 项目: botsing   文件: ProcessRunner.java
private static boolean executeProcess(File workDir, Log log, long timeout, String... command)
		throws InterruptedException, IOException {
	Process process = null;

	if (log.isDebugEnabled()) {
		log.debug("Going to execute command: " + String.join(" ", command));
	}

	try {
		ProcessBuilder builder = new ProcessBuilder(command);

		builder.directory(workDir.getAbsoluteFile());
		builder.redirectErrorStream(true);

		process = builder.start();
		handleProcessOutput(process, log);

		boolean exitResult = process.waitFor(timeout, TimeUnit.SECONDS);

		// process did not complete before timeout, kill it
		if (!exitResult) {
			log.error("Process terminated because it took more than " + timeout + "s to complete");
			throw new InterruptedException();
		}

		// Get process exitcode
		int exitCode = process.waitFor();

		if (exitCode != 0) {
			// process terminated abnormally
			log.error("Error executing process");
			return false;

		} else {
			// process terminated normally
			log.debug("Process terminated");
		}

	} catch (InterruptedException e) {
		if (process != null) {

			try {
				// be sure streamers are closed, otherwise process might
				// hang on Windows
				process.getOutputStream().close();
				process.getInputStream().close();
				process.getErrorStream().close();

			} catch (Exception t) {
				log.error("Failed to close process stream: " + t.toString());
			}

			process.destroy();

		}
		return false;

	}

	return true;
}
 
源代码19 项目: maven-replacer-plugin   文件: SummaryBuilder.java
public void add(String inputFile, String outputFile, String encoding, Log log) {
	String encodingUsed = encoding == null ? "(default)" : encoding;
	log.debug(String.format(FILE_DEBUG_FORMAT, inputFile, outputFile, encodingUsed));
	filesReplaced++;
}
 
源代码20 项目: siddhi   文件: DocumentationUtils.java
/**
 * Executing a command.
 *
 * @param command The command to be executed
 * @param logger  The maven plugin logger
 * @throws Throwable if any error occurs during the execution of the command
 */
private static void executeCommand(String[] command, Log logger) throws Throwable {
    List<String> executionOutputLines = getCommandOutput(command, logger);
    for (String executionOutputLine : executionOutputLines) {
        logger.debug(executionOutputLine);
    }
}