Package org.apache.maven.plugin.logging

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


            }
        }
    }

    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


   
    // 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

            }
        }
    }

    protected String convertFile(File file, String format) throws CommandLineException {
        Log log = getLog();
        if (!useDot) {
            log.info("DOT generation disabled.");
            return null;
        } else {           
            if (dotHelpExitCode() != 0) {
                log.info("'dot -?' execution failed so 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.createArg().setValue("-T" + format);
        cl.createArg().setValue("-o");
        cl.createArg().setValue(generatedFileName);
        cl.createArg().setValue(file.getAbsolutePath());

        log.debug("executing: " + cl.toString());

        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

        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

            }
        }
    }

    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.createArg().setValue("-T" + format);
        cl.createArg().setValue("-o");
        cl.createArg().setValue(generatedFileName);
        cl.createArg().setValue(file.getAbsolutePath());

        log.debug("executing: " + cl.toString());

        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

        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

     * cannot be created
     */
    public void execute()
            throws MojoExecutionException, MojoFailureException {

        Log log = getLog();

        // Check to see if the user asked for debug information, then dump all the
        // parameters we have picked up if they did.
        //
        if (log.isDebugEnabled()) {

            // Excludes
            //
            for (String e : excludes) {
                log.debug("ANTLR: Exclude: " + e);
            }

            // Includes
            //
            for (String e : includes) {
                log.debug("ANTLR: Include: " + e);
            }

            // Output location
            //
            log.debug("ANTLR: Output: " + outputDirectory);

            // Library directory
            //
            log.debug("ANTLR: Library: " + libDirectory);

            // Flags
            //
            log.debug("ANTLR: report              : " + report);
            log.debug("ANTLR: printGrammar        : " + printGrammar);
            log.debug("ANTLR: debug               : " + debug);
            log.debug("ANTLR: profile             : " + profile);
            log.debug("ANTLR: nfa                 : " + nfa);
            log.debug("ANTLR: dfa                 : " + dfa);
            log.debug("ANTLR: trace               : " + trace);
            log.debug("ANTLR: messageFormat       : " + messageFormat);
            log.debug("ANTLR: maxSwitchCaseLabels : " + maxSwitchCaseLabels);
            log.debug("ANTLR: minSwitchAlts       : " + minSwitchAlts);
            log.debug("ANTLR: verbose             : " + verbose);
        }

        // Ensure that the output directory path is all in tact so that
        // ANTLR can just write into it.
        //
        File outputDir = getOutputDirectory();

        if (!outputDir.exists()) {
            outputDir.mkdirs();
        }

        // First thing we need is an instance of the ANTLR 3.1 build tool
        //
        try {
            // ANTLR Tool buld interface
            //
            tool = new Tool();
        } catch (Exception e) {
            log.error("The attempt to create the ANTLR build tool failed, see exception report for details");

            throw new MojoFailureException("Jim failed you!");
        }

        // Next we need to set the options given to us in the pom into the
        // tool instance we have created.
        //
        tool.setDebug(debug);
        tool.setGenerate_DFA_dot(dfa);
        tool.setGenerate_NFA_dot(nfa);
        tool.setProfile(profile);
        tool.setReport(report);
        tool.setPrintGrammar(printGrammar);
        tool.setTrace(trace);
        tool.setVerbose(verbose);
        tool.setMessageFormat(messageFormat);
        tool.setMaxSwitchCaseLabels(maxSwitchCaseLabels);
        tool.setMinSwitchAlts(minSwitchAlts);

        // Where do we want ANTLR to produce its output? (Base directory)
        //
        if (log.isDebugEnabled())
        {
            log.debug("Output directory base will be " + outputDirectory.getAbsolutePath());
        }
        tool.setOutputDirectory(outputDirectory.getAbsolutePath());

        // Tell ANTLR that we always want the output files to be produced in the output directory
        // using the same relative path as the input file was to the input directory.
        //
        tool.setForceRelativeOutput(true);

        // Where do we want ANTLR to look for .tokens and import grammars?
        //
        tool.setLibDirectory(libDirectory.getAbsolutePath());

        if (!sourceDirectory.exists()) {
            if (log.isInfoEnabled()) {
                log.info("No ANTLR grammars to compile in " + sourceDirectory.getAbsolutePath());
            }
            return;
        } else {
            if (log.isInfoEnabled()) {
                log.info("ANTLR: Processing source directory " + sourceDirectory.getAbsolutePath());
            }
        }

        // Set working directory for ANTLR to be the base source directory
        //
        tool.setInputDirectory(sourceDirectory.getAbsolutePath());

        try {

            // Now pick up all the files and process them with the Tool
            //
            processGrammarFiles(sourceDirectory, outputDirectory);

        } catch (InclusionScanException ie) {

            log.error(ie);
            throw new MojoExecutionException("Fatal error occured while evaluating the names of the grammar files to analyze");

        } catch (Exception e) {

            getLog().error(e);
View Full Code Here

     * cannot be created
     */
    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {

        Log log = getLog();

        if (log.isDebugEnabled()) {
            for (String e : excludes) {
                log.debug("ANTLR: Exclude: " + e);
            }

            for (String e : includes) {
                log.debug("ANTLR: Include: " + e);
            }

            log.debug("ANTLR: Output: " + outputDirectory);
            log.debug("ANTLR: Library: " + libDirectory);
        }

    if (!sourceDirectory.isDirectory()) {
      log.info("No ANTLR 4 grammars to compile in " + sourceDirectory.getAbsolutePath());
      return;
    }

        // Ensure that the output directory path is all in tact so that
        // ANTLR can just write into it.
        //
        File outputDir = getOutputDirectory();

        if (!outputDir.exists()) {
            outputDir.mkdirs();
        }

    // Now pick up all the files and process them with the Tool
    //

    List<List<String>> argumentSets;
        try {
      List<String> args = getCommandArguments();
            argumentSets = processGrammarFiles(args, sourceDirectory);
        } catch (InclusionScanException ie) {
            log.error(ie);
            throw new MojoExecutionException("Fatal error occured while evaluating the names of the grammar files to analyze", ie);
        }

    log.debug("Output directory base will be " + outputDirectory.getAbsolutePath());
    log.info("ANTLR 4: Processing source directory " + sourceDirectory.getAbsolutePath());
    for (List<String> args : argumentSets) {
      try {
        // Create an instance of the ANTLR 4 build tool
        tool = new CustomTool(args.toArray(new String[args.size()]));
      } catch (Exception e) {
        log.error("The attempt to create the ANTLR 4 build tool failed, see exception report for details", e);
        throw new MojoFailureException("Error creating an instanceof the ANTLR tool.", e);
      }

      // Set working directory for ANTLR to be the base source directory
      tool.inputDirectory = sourceDirectory;
View Full Code Here

     *                                error occurs.
     */
    protected void copyFile( File artifact, File destFile )
        throws MojoExecutionException
    {
        Log theLog = this.getLog();
        try
        {
            theLog.info(
                "Copying " + ( this.outputAbsoluteArtifactFilename ? artifact.getAbsolutePath() : artifact.getName() )
                    + " to " + destFile );

            if ( artifact.isDirectory() )
            {
View Full Code Here

            artifactToNameMap.put(key, name);
        }
    }

    public void execute() throws MojoExecutionException {
        Log log = getLog();

        try {

            // Create the target directory
            File root;
            if (targetDirectory == null) {
                root = new File(project.getBuild().getDirectory(), "plugins/");
            } else {
                root = targetDirectory;
            }
            root.mkdirs();

            // Build sets of exclude directories and included/excluded/groupids
            Set<String> excludedFileNames = new HashSet<String>();
            if (excludeDirectories != null) {
                for (File f : excludeDirectories) {
                    if (f.isDirectory()) {
                        for (String n : f.list()) {
                            excludedFileNames.add(n);
                        }
                    }
                }
            }
            Set<String> includedGroupIds = new HashSet<String>();
            if (includeGroupIds != null) {
                for (String g : includeGroupIds) {
                    includedGroupIds.add(g);
                }
            }
            Set<String> excludedGroupIds = new HashSet<String>();
            if (excludeGroupIds != null) {
                for (String g : excludeGroupIds) {
                    excludedGroupIds.add(g);
                }
            }

            // Find all the distribution poms
            List<MavenProject> poms = new ArrayList<MavenProject>();
            poms.add(project);
            if (useDistributionName) {
                for (Object o : project.getArtifacts()) {
                    Artifact artifact = (Artifact)o;
                    if ("pom".equals(artifact.getType()) && artifact.getGroupId().equals(project.getGroupId())
                        && artifact.getArtifactId().startsWith("tuscany-feature-")) {
                        log.info("Dependent distribution: " + artifact);
                        MavenProject pomProject = buildProject(artifact);
                        poms.add(pomProject);
                        // log.info(pomProject.getArtifactMap().toString());
                    }
                }
            }

            // Process all the dependency artifacts
            ProjectSet bundleSymbolicNames = new ProjectSet(poms);
            ProjectSet bundleLocations = new ProjectSet(poms);
            ProjectSet jarNames = new ProjectSet(poms);
            for (Object o : project.getArtifacts()) {
                Artifact artifact = (Artifact)o;

                // Only consider Compile and Runtime dependencies
                if (!(Artifact.SCOPE_COMPILE.equals(artifact.getScope()) || Artifact.SCOPE_RUNTIME.equals(artifact
                    .getScope())
                    || Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) || (generateTargetPlatform && Artifact.SCOPE_TEST
                    .equals(artifact.getScope())))) {
                    log.info("Skipping artifact: " + artifact);
                    continue;
                }

                // Only consider JAR and WAR files
                if (!"jar".equals(artifact.getType()) && !"war".equals(artifact.getType())) {
                    continue;
                }

                // Exclude artifact if its groupId is excluded or if it's not included
                if (excludedGroupIds.contains(artifact.getGroupId())) {
                    log.debug("Artifact groupId is excluded: " + artifact);
                    continue;
                }
                if (!includedGroupIds.isEmpty()) {
                    if (!includedGroupIds.contains(artifact.getGroupId())) {
                        log.debug("Artifact groupId is not included: " + artifact);
                        continue;
                    }
                }

                File artifactFile = artifact.getFile();
                if (!artifactFile.exists()) {
                    log.warn("Artifact doesn't exist: " + artifact);
                    continue;
                }

                if (log.isDebugEnabled()) {
                    log.debug("Processing artifact: " + artifact);
                }

                // Get the bundle name if the artifact is an OSGi bundle
                String bundleName = null;
                try {
                    bundleName = BundleUtil.getBundleSymbolicName(artifact.getFile());
                } catch (IOException e) {
                    throw new MojoExecutionException(e.getMessage(), e);
                }

                if (bundleName != null) {

                    // Exclude artifact if its file name is excluded
                    if (excludedFileNames.contains(artifactFile.getName())) {
                        log.debug("Artifact file is excluded: " + artifact);
                        continue;
                    }

                    // Copy an OSGi bundle as is
                    log.info("Adding OSGi bundle artifact: " + artifact);
                    copyFile(artifactFile, root);
                    bundleSymbolicNames.add(artifact, bundleName);
                    bundleLocations.add(artifact, artifactFile.getName());
                    jarNames.add(artifact, artifactFile.getName());

                } else if ("war".equals(artifact.getType())) {

                    // Exclude artifact if its file name is excluded
                    if (excludedFileNames.contains(artifactFile.getName())) {
                        log.debug("Artifact file is excluded: " + artifact);
                        continue;
                    }

                    // Copy a WAR as is
                    log.info("Adding WAR artifact: " + artifact);
                    copyFile(artifactFile, root);

                } else {

                    //                    String version = BundleUtil.osgiVersion(artifact.getVersion());
                    //                    String symbolicName = (artifact.getGroupId() + "." + artifact.getArtifactId());
                    //                    String dirName = symbolicName + "_" + version;

                    String dirName = artifactFile.getName().substring(0, artifactFile.getName().length() - 4);
                    File dir = new File(root, dirName);

                    // Exclude artifact if its file name is excluded
                    if (excludedFileNames.contains(dir.getName())) {
                        log.debug("Artifact file is excluded: " + artifact);
                        continue;
                    }

                    if (artifactAggregations != null) {
                        boolean aggregated = false;
                        for (ArtifactAggregation group : artifactAggregations) {
                            if (group.matches(artifact)) {
                                group.getArtifacts().add(artifact);
                                aggregated = true;
                                break;
                            }
                        }
                        if (aggregated) {
                            continue;
                        }
                    }

                    // Create a bundle directory for a non-OSGi JAR
                    log.info("Adding JAR artifact: " + artifact);
                    String version = BundleUtil.osgiVersion(artifact.getVersion());

                    Set<File> jarFiles = new HashSet<File>();
                    jarFiles.add(artifactFile);
                    String symbolicName = (artifact.getGroupId() + "." + artifact.getArtifactId());
                    Manifest mf = BundleUtil.libraryManifest(jarFiles, symbolicName, symbolicName, version, null);
                    File file = new File(dir, "META-INF");
                    file.mkdirs();
                    file = new File(file, "MANIFEST.MF");

                    FileOutputStream fos = new FileOutputStream(file);
                    write(mf, fos);
                    fos.close();
                    copyFile(artifactFile, dir);
                    bundleSymbolicNames.add(artifact, symbolicName);
                    bundleLocations.add(artifact, dir.getName());
                    jarNames.add(artifact, dirName + "/" + artifactFile.getName());
                }
            }

            if (artifactAggregations != null) {
                for (ArtifactAggregation group : artifactAggregations) {
                    if (group.getArtifacts().isEmpty()) {
                        continue;
                    }
                    String symbolicName = group.getSymbolicName();
                    String version = group.getVersion();
                    File dir = new File(root, symbolicName + "-" + version);
                    dir.mkdir();
                    Set<File> jarFiles = new HashSet<File>();
                    Artifact artifact = null;
                    for (Artifact a : group.getArtifacts()) {
                        log.info("Aggragating JAR artifact: " + a);
                        artifact = a;
                        jarFiles.add(a.getFile());
                        copyFile(a.getFile(), dir);
                        jarNames.add(a, symbolicName + "-" + version + "/" + a.getFile().getName());
                    }
View Full Code Here

     * @parameter
     */
    private String symbolicName;

    public void execute() throws MojoExecutionException {
        Log log = getLog();

        String projectGroupId = project.getGroupId();
        Set<File> jarFiles = new HashSet<File>();
        for (Object o : project.getArtifacts()) {
            Artifact artifact = (Artifact)o;

            if (!(Artifact.SCOPE_COMPILE.equals(artifact.getScope()) || Artifact.SCOPE_RUNTIME.equals(artifact
                .getScope()))) {
                if (log.isDebugEnabled()) {
                    log.debug("Skipping artifact: " + artifact);
                }
                continue;
            }
            if (!"jar".equals(artifact.getType())) {
                continue;
            }
            if (projectGroupId.equals(artifact.getGroupId())) {
                continue;
            }

            if (log.isDebugEnabled()) {
                log.debug("Artifact: " + artifact);
            }
            String bundleName = null;
            try {
                bundleName = BundleUtil.getBundleSymbolicName(artifact.getFile());
            } catch (IOException e) {
                throw new MojoExecutionException(e.getMessage(), e);
            }
            if (bundleName == null || true) {
                if (artifact.getFile().exists()) {
                    log.info("Adding third party jar: " + artifact);
                    jarFiles.add(artifact.getFile());
                } else {
                    log.warn("Third party jar not found: " + artifact);
                }
            }
        }

        try {
            String version = BundleUtil.osgiVersion(project.getVersion());

            Manifest mf = BundleUtil.libraryManifest(jarFiles, project.getName(), symbolicName, version, "lib");
            File file = new File(project.getBasedir(), "META-INF");
            file.mkdir();
            file = new File(file, "MANIFEST.MF");
            if (log.isDebugEnabled()) {
                log.debug("Generating " + file);
            }

            FileOutputStream fos = new FileOutputStream(file);
            write(mf, fos);
            fos.close();

            File lib = new File(project.getBasedir(), "lib");
            if (lib.isDirectory()) {
                for (File c : lib.listFiles()) {
                    c.delete();
                }
            }
            lib.mkdir();
            byte[] buf = new byte[4096];
            for (File jar : jarFiles) {
                File jarFile = new File(lib, jar.getName());
                if (log.isDebugEnabled()) {
                    log.debug("Copying " + jar + " to " + jarFile);
                }
                FileInputStream in = new FileInputStream(jar);
                FileOutputStream out = new FileOutputStream(jarFile);
                for (;;) {
                    int len = in.read(buf);
View Full Code Here

        }

        if (verifyParameters()) {
            OSGiSurefireBooter surefireBooter = constructSurefireBooter();
           
            Log log = getLog();
            Set<String> jarFiles = new HashSet<String>();
           
            /*
            for (Object o : project.getArtifacts()) {
                Artifact a = (Artifact)o;
                if ("pom".equals(a.getType())) {
                    // Skip pom projects
                    continue;
                }
                try {
                    if (log.isDebugEnabled()) {
                        log.debug("Adding: " + a);
                    }
                    jarFiles.add(a.getFile().toURI().toURL());
                } catch (MalformedURLException e) {
                    getLog().error(e);
                }
            }
            */

            /*
             * Add org.apache.tuscany.sca:tuscany-extensibility-osgi module
             */
            String aid = "tuscany-extensibility-equinox";
            Artifact ext = getArtifact("org.apache.tuscany.sca", aid);
            if (log.isDebugEnabled()) {
                log.debug("Adding: " + ext);
            }
            jarFiles.add(ext.getFile().getAbsolutePath());


            String name = project.getBuild().getFinalName();
            String mainBundleName = null;
            File mainJar = new File(project.getBuild().getDirectory(), name + "-osgi.jar");
            File testJar = new File(project.getBuild().getDirectory(), name + "-osgi-tests.jar");
            try {
                Manifest manifest = createMainBundle();
                mainBundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
                int sc = mainBundleName.indexOf(';');
                if (sc != -1) {
                    mainBundleName = mainBundleName.substring(0, sc);
                }
                generateJar(classesDirectory, mainJar, manifest);
                Manifest testManifest = createTestFragment(manifest);
                generateJar(testClassesDirectory, testJar, testManifest);
                jarFiles.add(mainJar.getAbsolutePath());
                jarFiles.add(testJar.getAbsolutePath());
            } catch (IOException e) {
                getLog().error(e);
            }

            if (log.isDebugEnabled()) {
                log.debug("Main bundle: " + mainBundleName);
            }
            surefireBooter.setMainBundleName(mainBundleName);
            for (String url : jarFiles) {
                surefireBooter.addClassPathUrl(url);
            }           
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.