コード例 #1
0
 /** Create the {@link ResourceFinderImpl} for the project */
 @SuppressWarnings("unchecked")
 protected ResourceFinder getResourceFinder() throws MojoExecutionException {
   final ResourceFinder finder = new ResourceFinderImpl(this.project);
   try {
     final List<String> classpathElements = this.project.getCompileClasspathElements();
     finder.setCompileClassPath(classpathElements);
   } catch (DependencyResolutionRequiredException e) {
     throw new MojoExecutionException(e.getMessage(), e);
   }
   finder.setPluginClassPath(getClass().getClassLoader());
   return finder;
 }
コード例 #2
0
  /**
   * Read the template notice file into a string, converting the line ending to the current OS line
   * endings
   */
  protected String readNoticeTemplate(ResourceFinder finder) throws MojoFailureException {
    final URL inputFile = finder.findResource(this.noticeTemplate);

    final StringBuilder noticeTemplateContents = new StringBuilder();
    InputStream inputStream = null;
    try {
      inputStream = inputFile.openStream();
      for (final LineIterator lineIterator =
              IOUtils.lineIterator(new BufferedInputStream(inputStream), this.encoding);
          lineIterator.hasNext(); ) {
        final String line = lineIterator.next();
        noticeTemplateContents.append(line).append(IOUtils.LINE_SEPARATOR);
      }
    } catch (IOException e) {
      throw new MojoFailureException(
          "Failed to open NOTICE Template File '" + this.noticeTemplate + "' from: " + inputFile,
          e);
    } finally {
      IOUtils.closeQuietly(inputStream);
    }

    return noticeTemplateContents.toString();
  }