Package org.apache.maven.plugin.logging

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


   * bad {@link URL} was encountered
   *
   * @see #toURLs(Artifact)
   */
  private final ClassLoader toClassLoader(final Iterable<? extends Artifact> artifacts) throws MalformedURLException {
    final Log log = this.getLog();
    ClassLoader loader = null;
    if (artifacts != null) {
      final Collection<URL> urls = new ArrayList<URL>();
      for (final Artifact artifact : artifacts) {
        final Collection<? extends URL> classpathElements = this.toURLs(artifact);
        if (classpathElements != null && !classpathElements.isEmpty()) {
          urls.addAll(classpathElements);
        }
      }
      if (!urls.isEmpty()) {
        if (log != null && log.isDebugEnabled()) {
          log.debug(String.format("Creating URLClassLoader with the following classpath: %s", urls));
        }
        loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), Thread.currentThread().getContextClassLoader());
      }
    }
    return loader;
View Full Code Here


    public void execute() throws MojoExecutionException {
        if (project.getPackaging().equals("pom")) {
            return;
        }

        Log log = getLog();
        List<URL> jarFiles = new ArrayList<URL>();
        for (Object o : project.getArtifacts()) {
            Artifact a = (Artifact)o;
            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 = "equinox".equals(osgiRuntime) ? "tuscany-extensibility-equinox" : "tuscany-extensibility-osgi";
        Artifact ext = getArtifact("org.apache.tuscany.sca", aid);
        try {
            URL url = ext.getFile().toURI().toURL();
            if (!jarFiles.contains(url)) {
                if (log.isDebugEnabled()) {
                    log.debug("Adding: " + ext);
                }
                jarFiles.add(url);
            }
        } catch (MalformedURLException e) {
            getLog().error(e);
View Full Code Here

        try
        {
            Class<?> generatorClass = Thread.currentThread().getContextClassLoader().loadClass( generatorClassName );

            Log log = new SystemStreamLog();
            try
            {
                Constructor<?> constructor = generatorClass.getConstructor( Log.class );
                generator = (Generator) constructor.newInstance( log );
            }
View Full Code Here

            throw new MojoExecutionException(e.getMessage(), e);
        }
    }

    private void showDependencies() {
        Log log = getLog();
        if (!log.isDebugEnabled()) {
            return;
        }
        log.debug("The projects dependency artifacts are: ");
        for (Iterator iter = project.getDependencyArtifacts().iterator(); iter.hasNext();) {
            Artifact artifact = (Artifact)iter.next();
            log.debug("    " + artifact.getGroupId() + ":" + artifact.getArtifactId() +
                    ":" + artifact.getVersion() + ":" + artifact.getClassifier() +
                    ":" + artifact.getScope() + ":" + artifact.getType());
        }
        log.debug("The projects transitive artifacts are: ");
        for (Iterator iter = project.getArtifacts().iterator(); iter.hasNext();) {
            Artifact artifact = (Artifact)iter.next();
            log.debug("    " + artifact.getGroupId() + ":" + artifact.getArtifactId() +
                    ":" + artifact.getVersion() + ":" + artifact.getClassifier() +
                    ":" + artifact.getScope() + ":" + artifact.getType());
        }
    }
View Full Code Here

      // create final PEAR file object
      File finalPearFileName = new File(this.targetDir, this.componentId
            + ".pear");

      // log PEAR packaging details
      Log log = getLog();
      log.info("Start building PEAR package for component " + this.componentId);
      log.debug("UIMA PEAR INFORMATION ");
      log.debug("======================");
      log.debug("main component dir:   " + this.mainComponentDir);
      log.debug("main component desc:  " + this.mainComponentDesc);
      log.debug("component id:         " + this.componentId);
      log.debug("classpath:            " + this.classpath);
      log.debug("datapath:             " + this.datapath);
      log.debug("target dir:           " + this.targetDir);
      log.debug("pear packaging dir:   "
            + this.pearPackagingDir.getAbsolutePath());
      log.debug("final PEAR file:      " + finalPearFileName.getAbsolutePath());

      // check Maven project packaging type - only jar packaging is supported
      if (!this.project.getPackaging().equals("jar")) {
         throw new MojoExecutionException(
               "Wrong packaging type, only 'jar' packaging is supported");
      }

      try {
         // copies all PEAR data to the PEAR packaging directory
         copyPearData();

         // copy created jar package to the PEAR packaging lib directory
         // get jar file name
         String jarFileName = this.project.getBuild().getFinalName() + ".jar";
         // get jar file location
         File finalJarFile = new File(this.project.getBuild().getDirectory(),
               jarFileName);
         // check if the jar file exist
         if (finalJarFile.exists()) {
            // specify the target directory for the jar file
            File target = new File(this.pearPackagingDir,
                  InstallationController.PACKAGE_LIB_DIR);
            File targetFile = new File(target, jarFileName);
            // copy the jar file to the target directory
            FileUtils.copyFile(finalJarFile, targetFile);
         } else {
            // jar file does not exist - build was not successful
            String errorMessage = "Jar package "
                  + finalJarFile.getAbsolutePath() + " not found";
            log.debug(errorMessage);
            throw new IOException(errorMessage);
         }

         // add compiled jar to the PEAR classpath
         StringBuffer buffer = new StringBuffer();
         buffer.append(";$main_root/");
         buffer.append(InstallationController.PACKAGE_LIB_DIR);
         buffer.append("/");
         buffer.append(this.project.getBuild().getFinalName());
         buffer.append(".jar");
         String classpathExtension = buffer.toString();
         if(this.classpath != null) {
            this.classpath = this.classpath + classpathExtension;
         } else {
            this.classpath = classpathExtension.substring(1,classpathExtension.length());
         }

         // create the PEAR package
         createPear();

         // log success message
         log.info("PEAR package for component " + this.componentId
               + " successfully created at: "
               + finalPearFileName.getAbsolutePath());

         // set UIMA logger back to the original log level
         UIMAFramework.getLogger().setLevel(level);

      } catch (PackageCreatorException e) {
         log.debug(e.getMessage());
         throw new MojoExecutionException(e.getMessage());
      } catch (IOException e) {
         log.debug(e.getMessage());
         throw new MojoExecutionException(e.getMessage());
      }

   }
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

            }
        }
    }

    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

            }
        }
    }

    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

            throw new MojoExecutionException(e.getMessage(), e);
        }
    }

    private void showDependencies() {
        Log log = getLog();
        if (!log.isDebugEnabled()) {
            return;
        }
        log.debug("The projects dependency artifacts are: ");
        for (Iterator iter = project.getDependencyArtifacts().iterator(); iter.hasNext();) {
            Artifact artifact = (Artifact)iter.next();
            log.debug("    " + artifact.getGroupId() + ":" + artifact.getArtifactId() +
                    ":" + artifact.getVersion() + ":" + artifact.getClassifier() +
                    ":" + artifact.getScope() + ":" + artifact.getType());
        }
        log.debug("The projects transitive artifacts are: ");
        for (Iterator iter = project.getArtifacts().iterator(); iter.hasNext();) {
            Artifact artifact = (Artifact)iter.next();
            log.debug("    " + artifact.getGroupId() + ":" + artifact.getArtifactId() +
                    ":" + artifact.getVersion() + ":" + artifact.getClassifier() +
                    ":" + artifact.getScope() + ":" + artifact.getType());
        }
    }
View Full Code Here

     */
    public void execute( EnforcerRuleHelper helper )
        throws EnforcerRuleException
    {
        String java_version = SystemUtils.JAVA_VERSION_TRIMMED;
        Log log = helper.getLog();

        log.debug( "Detected Java String: " + java_version );
        java_version = normalizeJDKVersion( java_version );
        log.debug( "Normalized Java String: " + java_version );

        ArtifactVersion detectedJdkVersion = new DefaultArtifactVersion( java_version );

        log.debug( "Parsed Version: Major: " + detectedJdkVersion.getMajorVersion() + " Minor: " +
            detectedJdkVersion.getMinorVersion() + " Incremental: " + detectedJdkVersion.getIncrementalVersion() +
            " Build: " + detectedJdkVersion.getBuildNumber() + " Qualifier: " + detectedJdkVersion.getQualifier() );

        enforceVersion( helper.getLog(), "JDK", version, detectedJdkVersion );
    }
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.