Package org.apache.maven.plugin.logging

Examples of org.apache.maven.plugin.logging.Log


     * @throws MojoExecutionException
     */
    protected void buildArchive(Archiver archiver)
            throws ArchiverException, MojoExecutionException {
       
        Log log = getLog();
        log.debug("Using base directory: " + baseDir);
        archiver.addDirectory(buildOutputDirectory);
        if (includeDependencies) {
            log.debug("Adding dependencies ...");
            addDependencies(archiver);
        }
        if (generateMetadata) {
            log.debug("Generating XAR metadata ...");
            generateMetadata(archiver);
        }
    }
View Full Code Here


    }
   
    private void addDependencies(Archiver archiver)
            throws ArchiverException, MojoExecutionException {
       
        Log log = getLog();
        AndArtifactFilter filter = new AndArtifactFilter();
        filter.add(new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME));
        filter.add(new ArtifactFilter() {
            public boolean include(Artifact artifact) {
                return !artifact.isOptional();
            }
        });
        filter.add(new TypeArtifactFilter("jar"));
        filter.add(buildSynapseRuntimeArtifactFilter());
        for (Artifact artifact : filterArtifacts(project.getArtifacts(), filter)) {
            String targetFileName = artifact.getArtifactId() + "-" + artifact.getVersion() + "." +
                    artifact.getArtifactHandler().getExtension();
            log.info("Adding " + targetFileName + " (scope " + artifact.getScope() + ")");
            archiver.addFile(artifact.getFile(), "lib/" + targetFileName);
        }
    }
View Full Code Here

    }
   
    private void generateMetadata(Archiver archiver)
            throws ArchiverException, MojoExecutionException {
       
        Log log = getLog();
        File tmpServicesDir = new File(new File(tmpDirectory, "META-INF"), "services");
        File buildServicesDir = new File(new File(buildOutputDirectory, "META-INF"), "services");
        if (!tmpServicesDir.exists() && !tmpServicesDir.mkdirs()) {
            throw new MojoExecutionException("Error while creating the directory: " +
                    tmpServicesDir.getPath());
        }
       
        log.debug("Initializing class scanner ...");
        ClassScanner scanner = new ClassScanner(buildOutputDirectory);
        for (Artifact artifact : filterArtifacts(project.getArtifacts(),
                new ScopeArtifactFilter(Artifact.SCOPE_COMPILE))) {
            scanner.addToClasspath(artifact.getFile());
        }
        List<ServiceLocator> serviceLocators =
            new ArrayList<ServiceLocator>(serviceClassNames.length);
        for (String serviceClassName : serviceClassNames) {
            // If the user provided its own service file, skip generation
            File file = new File(buildServicesDir, serviceClassName);
            if (file.exists()) {
                log.debug(file + " exists; don't scan for " + serviceClassName +
                        " implementation");
            } else {
                ServiceLocator sl = new ServiceLocator(serviceClassName);
                serviceLocators.add(sl);
                scanner.addVisitor(sl);
            }
        }
        try {
            scanner.scan();
        } catch (ClassScannerException e) {
            throw new MojoExecutionException("Failed to scan classes for services", e);
        }
        for (ServiceLocator sl : serviceLocators) {
            File file = new File(tmpServicesDir, sl.getServiceClassName());
            if (!sl.getImplementations().isEmpty()) {
                String destFileName = "META-INF/services/" + sl.getServiceClassName();
                log.info("Generating " + destFileName);
                try {
                    Writer out = new OutputStreamWriter(new FileOutputStream(file));
                    try {
                        for (String impl : sl.getImplementations()) {
                            log.debug("  " + impl);
                            out.write(impl);
                            out.write("\n");
                        }
                    } finally {
                        out.close();
View Full Code Here

     *
     * @return
     * @throws MojoExecutionException
     */
    private Set<Artifact> getSynapseRuntimeArtifacts() throws MojoExecutionException {
        Log log = getLog();
        log.debug("Looking for synapse-core artifact in XAR project dependencies ...");
        Artifact synapseCore = null;
        for (Iterator<?> it = project.getDependencyArtifacts().iterator(); it.hasNext(); ) {
            Artifact artifact = (Artifact)it.next();
            if (artifact.getGroupId().equals("org.apache.synapse")
                    && artifact.getArtifactId().equals("synapse-core")) {
                synapseCore = artifact;
                break;
            }
        }
        if (synapseCore == null) {
            throw new MojoExecutionException("Could not locate dependency on synapse-core");
        }
       
        log.debug("Loading project data for " + synapseCore + " ...");
        MavenProject synapseCoreProject;
        try {
            synapseCoreProject = projectBuilder.buildFromRepository(synapseCore,
                    remoteArtifactRepositories, localRepository);
        } catch (ProjectBuildingException e) {
            throw new MojoExecutionException("Unable to retrieve project information for "
                    + synapseCore, e);
        }
        Set<Artifact> synapseRuntimeDeps;
        try {
            synapseRuntimeDeps = synapseCoreProject.createArtifacts(artifactFactory,
                    Artifact.SCOPE_RUNTIME, new TypeArtifactFilter("jar"));
        } catch (InvalidDependencyVersionException e) {
            throw new MojoExecutionException("Unable to get project dependencies for "
                    + synapseCore, e);
        }
        log.debug("Direct runtime dependencies for " + synapseCore + " :");
        logArtifacts(synapseRuntimeDeps);
       
        log.debug("Resolving transitive dependencies for " + synapseCore + " ...");
        try {
            synapseRuntimeDeps = artifactCollector.collect(synapseRuntimeDeps,
                    synapseCoreProject.getArtifact(), synapseCoreProject.getManagedVersionMap(),
                    localRepository, remoteArtifactRepositories, artifactMetadataSource, null,
                    Collections.singletonList(new DebugResolutionListener(logger))).getArtifacts();
        } catch (ArtifactResolutionException e) {
            throw new MojoExecutionException("Unable to resolve transitive dependencies for "
                    + synapseCore);
        }
        log.debug("All runtime dependencies for " + synapseCore + " :");
        logArtifacts(synapseRuntimeDeps);
       
        return synapseRuntimeDeps;
    }
View Full Code Here

    // AbstractPlutoMojo Impl --------------------------------------------------
   
    protected void doExecute() throws Exception {
        // Log parameter values.
      Log log = getLog();
        if (log.isInfoEnabled()) {
            log.info("Reading web.xml from :" + webXml.getAbsolutePath());
            log.info("Reading portlet.xml from: " + portletXml.getAbsolutePath());
            log.info("Writing web.xml to: " + webXmlDestination.getAbsolutePath());
        }
        // Assemble portlet app by updating web.xml.
        AssemblerConfig config = createAssemblerConfig();
        Assembler assembler = AssemblerFactory.getFactory()
            .createAssembler(config);
View Full Code Here

     */
    @SuppressWarnings( { "UnusedDeclaration" })
    private MavenProject project;

    public void execute() throws MojoExecutionException, MojoFailureException {
        Log log = getLog();
        log.info("Validating RHQ Plugin");

        // Determine where the plugin is
        String pluginJarName = project.getArtifactId() + "-" + project.getVersion() + ".jar";
        String pluginDirectory = project.getBasedir().getAbsolutePath();

        log.debug("Plugin JAR: " + pluginJarName);
        log.debug("Plugin Directory: " + pluginDirectory);

        File pluginFile = new File(pluginDirectory, pluginJarName);
        if (!pluginFile.exists()) {
            throw new MojoFailureException("Cannot find plugin");
        }

        // Load into validator
        URL pluginUrl;
        try {
            pluginUrl = pluginFile.toURL();
        } catch (MalformedURLException e) {
            throw new MojoFailureException("Could not load URL for plugin file: " + pluginFile);
        }

        log.info("Plugin descriptor directory URL:" + pluginUrl);

        SimplePluginFinder finder = new SimplePluginFinder(pluginUrl);

        // Validate
        boolean success = PluginValidator.validatePlugins(finder);

        if (success) {
            log.info("--------------------------");
            log.info("Plugin Validation: SUCCESS");
            log.info("--------------------------");
        } else {
            log.info("--------------------------");
            log.info("Plugin Validation: FAILURE");
            log.info("--------------------------");
            throw new MojoFailureException("Plugin validation failed. Check the rest of the log for more information.");
        }
    }
View Full Code Here

       
        getLog().info("listing jdbc resources");
        Collection<JDBCResourceConfig> configs = getAppServer()
            .getJDBCResourceConfigs();
       
        Log log = getLog();
       
        StringBuilder builder = new StringBuilder();
        for (JDBCResourceConfig config : configs) {
            builder.append("jndi name=[").append(config.getName()).append("],")
                .append("enabled=[").append(config.getEnabled()).append("],")
                .append("connection pool=[").append(
                        config.getPoolName()).append("]\n");
        }
       
        log.info(builder.toString());
    }
View Full Code Here

       
        getLog().info("listing jdbc pool connection");
        Collection<JDBCConnectionPoolConfig> configs = getAppServer()
            .getJDBCConnectionPoolConfigs();
       
        Log log = getLog();
       
        StringBuilder builder = new StringBuilder();
        for (JDBCConnectionPoolConfig config : configs) {
            builder.append("name=[").append(config.getName()).append("],")
                .append("resType=[").append(config.getResType()).append("],")
                .append("datasourceClassname=[").append(
                        config.getDatasourceClassname()).append("]\n");
        }
       
        log.info(builder.toString());
    }
View Full Code Here

       
        getLog().info("listing mail resources");
        Collection<MailResourceConfig> configs = getAppServer()
            .getMailResourceConfigs();
       
        Log log = getLog();
       
        StringBuilder builder = new StringBuilder();
        for (MailResourceConfig config : configs) {
            builder.append("jndi name=[").append(config.getName()).append("],")
                .append("enabled=[").append(config.getEnabled()).append("]\n");
        }
       
        log.info(builder.toString());
    }
View Full Code Here

            }
        }
    }

    protected String convertFile(File file, String format) throws CommandLineException {
        Log log = getLog();
        if (!useDot) {
            log.info("DOT generation disabled");
            return null;
        }
        if (this.executable == null || this.executable.length() == 0) {
            log.warn("Parameter <executable/> was not set in the pom.xml.  Skipping conversion.");
            return null;
        }

        String generatedFileName = removeFileExtension(file.getAbsolutePath()) + "." + format;
        Commandline cl = new Commandline();
        cl.setExecutable(executable);
        cl.createArgument().setValue("-T" + format);
        cl.createArgument().setValue("-o");
        cl.createArgument().setValue(generatedFileName);
        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 generatedFileName;
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.plugin.logging.Log

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.