Fork me on GitHub

CPD Results

The following document contains the results of PMD's CPD 7.3.0.

Duplications

File Line
org\codehaus\gmavenplus\mojo\GroovyDocJarMojo.java 135
org\codehaus\gmavenplus\mojo\GroovyDocTestsJarMojo.java 135
getLog().info("Not adding GroovyDoc jar to attached artifacts list.");
            }
        } catch (ArchiverException e) {
            throw new MojoExecutionException("ArchiverException: Error while creating archive", e);
        } catch (IOException e) {
            throw new MojoExecutionException("IOException: Error while creating archive", e);
        } catch (RuntimeException e) {
            throw new MojoExecutionException("RuntimeException: Error while creating archive", e);
        }
    }

    /**
     * Method that creates the jar file
     *
     * @param groovydocFiles the directory where the generated jar file will be put
     * @param jarFileName    the filename of the generated jar file
     * @return a File object that contains the generated jar file
     * @throws ArchiverException When an issue occurs preventing Maven Archiver from creating the jar file
     * @throws IOException       When an IO issue occurs preventing Maven Archiver from creating the jar file
     */
    protected File generateArchive(File groovydocFiles, String jarFileName) throws ArchiverException, IOException {
        File groovydocJar = new File(jarOutputDirectory, jarFileName);

        if (groovydocJar.exists()) {
            if (!groovydocJar.delete()) {
                getLog().warn("Unable to delete " + groovydocJar.getAbsolutePath());
            }
        }

        MavenArchiver archiver = new MavenArchiver();
        archiver.setArchiver(jarArchiver);
        archiver.setOutputFile(groovydocJar);

        if (!groovydocFiles.exists()) {
            getLog().warn("JAR will be empty - no content was marked for inclusion!");
        } else {
            archiver.getArchiver().addDirectory(groovydocFiles);
        }

        if (useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile() == null) {
            getLog().info("Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath());
            archive.setManifestFile(defaultManifestFile);
        }

        try {
            archiver.createArchive(session, project, archive);
        } catch (ManifestException e) {
            throw new ArchiverException("ManifestException: " + e.getMessage(), e);
        } catch (DependencyResolutionRequiredException e) {
            throw new ArchiverException("DependencyResolutionRequiredException: " + e.getMessage(), e);
        }

        return groovydocJar;
    }

}
File Line
org\codehaus\gmavenplus\mojo\AbstractGenerateStubsMojo.java 255
org\codehaus\gmavenplus\mojo\AbstractGroovyDocMojo.java 379
} catch (java.io.IOException | InterruptedException e) {
            throw new InvocationTargetException(e);
        }
    }

    protected String buildForkClasspath() {
        StringBuilder cp = new StringBuilder();
        // Add plugin artifact
        cp.append(pluginDescriptor.getPluginArtifact().getFile().getAbsolutePath());

        // Add plugin dependencies
        for (org.apache.maven.artifact.Artifact artifact : pluginDescriptor.getArtifacts()) {
            cp.append(File.pathSeparator);
            cp.append(artifact.getFile().getAbsolutePath());
        }

        // Add maven-plugin-api jar which is 'provided' so not in getArtifacts()
        try {
            Class<?> logClass = org.apache.maven.plugin.logging.Log.class;
            java.security.CodeSource codeSource = logClass.getProtectionDomain().getCodeSource();
            if (codeSource != null) {
                String logJar = new File(codeSource.getLocation().toURI()).getAbsolutePath();
                cp.append(File.pathSeparator).append(logJar);
            }
        } catch (Exception e) {
            getLog().warn("Could not find maven-plugin-api jar to add to fork classpath", e);
        }

        return cp.toString();
    }

    /**
     * Logs the stubs that have been generated.
     *
     * @param outputDirectory the output directory for the stubs
     */
    protected void logGeneratedStubs(File outputDirectory) {
File Line
org\codehaus\gmavenplus\mojo\AbstractCompileMojo.java 301
org\codehaus\gmavenplus\mojo\AbstractGenerateStubsMojo.java 256
org\codehaus\gmavenplus\mojo\AbstractGroovyDocMojo.java 380
throw new RuntimeException("Unable to fork compilation", e);
        }
    }

    protected String buildForkClasspath() {
        StringBuilder cp = new StringBuilder();
        // Add plugin artifact
        cp.append(pluginDescriptor.getPluginArtifact().getFile().getAbsolutePath());

        // Add plugin dependencies
        for (org.apache.maven.artifact.Artifact artifact : pluginDescriptor.getArtifacts()) {
            cp.append(File.pathSeparator);
            cp.append(artifact.getFile().getAbsolutePath());
        }

        // Add maven-plugin-api jar which is 'provided' so not in getArtifacts()
        try {
            Class<?> logClass = org.apache.maven.plugin.logging.Log.class;
            java.security.CodeSource codeSource = logClass.getProtectionDomain().getCodeSource();
            if (codeSource != null) {
                String logJar = new File(codeSource.getLocation().toURI()).getAbsolutePath();
                cp.append(File.pathSeparator).append(logJar);
            }
        } catch (Exception e) {
            getLog().warn("Could not find maven-plugin-api jar to add to fork classpath", e);
        }

        return cp.toString();
    }
File Line
org\codehaus\gmavenplus\model\GroovyCompileConfiguration.java 66
org\codehaus\gmavenplus\model\GroovyStubConfiguration.java 60
}

    public IncludeClasspath getIncludeClasspath() {
        return includeClasspath;
    }

    public void setIncludeClasspath(IncludeClasspath includeClasspath) {
        this.includeClasspath = includeClasspath;
    }

    public boolean isSkipBytecodeCheck() {
        return skipBytecodeCheck;
    }

    public void setSkipBytecodeCheck(boolean skipBytecodeCheck) {
        this.skipBytecodeCheck = skipBytecodeCheck;
    }

    public boolean isDebug() {
        return debug;
    }

    public void setDebug(boolean debug) {
        this.debug = debug;
    }

    public boolean isVerbose() {
        return verbose;
    }

    public void setVerbose(boolean verbose) {
        this.verbose = verbose;
    }

    public int getWarningLevel() {
        return warningLevel;
    }

    public void setWarningLevel(int warningLevel) {
        this.warningLevel = warningLevel;
    }

    public int getTolerance() {
        return tolerance;
    }

    public void setTolerance(int tolerance) {
        this.tolerance = tolerance;
    }

    public boolean isInvokeDynamic() {
File Line
org\codehaus\gmavenplus\mojo\ConsoleMojo.java 70
org\codehaus\gmavenplus\mojo\ShellMojo.java 75
public void execute() throws MojoExecutionException, MojoFailureException {
        try {
            setupClassWrangler(project.getTestClasspathElements(), includeClasspath);
        } catch (MalformedURLException e) {
            throw new MojoExecutionException("Unable to add project test dependencies to classpath.", e);
        } catch (DependencyResolutionRequiredException e) {
            throw new MojoExecutionException("Test dependencies weren't resolved.", e);
        }

        logPluginClasspath();
        classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());

        try {
            getLog().debug("Project test classpath:\n" + project.getTestClasspathElements());
        } catch (DependencyResolutionRequiredException e) {
            getLog().debug("Unable to log project test classpath");
        }

        if (!groovyVersionSupportsAction()) {
            getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support running a console. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping console startup.");
File Line
org\codehaus\gmavenplus\mojo\ConsoleMojo.java 71
org\codehaus\gmavenplus\mojo\ExecuteMojo.java 139
org\codehaus\gmavenplus\mojo\ShellMojo.java 76
try {
            setupClassWrangler(project.getTestClasspathElements(), includeClasspath);
        } catch (MalformedURLException e) {
            throw new MojoExecutionException("Unable to add project test dependencies to classpath.", e);
        } catch (DependencyResolutionRequiredException e) {
            throw new MojoExecutionException("Test dependencies weren't resolved.", e);
        }

        logPluginClasspath();
        classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());

        try {
            getLog().debug("Project test classpath:\n" + project.getTestClasspathElements());
        } catch (DependencyResolutionRequiredException e) {
            getLog().debug("Unable to log project test classpath");
        }

        if (!groovyVersionSupportsAction()) {
            getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support running a console. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping console startup.");
File Line
org\codehaus\gmavenplus\util\GroovyCompiler.java 521
org\codehaus\gmavenplus\util\GroovyCompiler.java 618
invokeMethod(findMethod(compilerConfigurationClass, "setDebug", boolean.class), compilerConfiguration, configuration.isDebug());
        invokeMethod(findMethod(compilerConfigurationClass, "setVerbose", boolean.class), compilerConfiguration, configuration.isVerbose());
        invokeMethod(findMethod(compilerConfigurationClass, "setWarningLevel", int.class), compilerConfiguration, configuration.getWarningLevel());
        invokeMethod(findMethod(compilerConfigurationClass, "setTolerance", int.class), compilerConfiguration, configuration.getTolerance());
        invokeMethod(findMethod(compilerConfigurationClass, "setTargetBytecode", String.class), compilerConfiguration, translateJavacTargetToTargetBytecode(configuration.getTargetBytecode()));
        if (configuration.getSourceEncoding() != null) {
File Line
org\codehaus\gmavenplus\mojo\ConsoleMojo.java 179
org\codehaus\gmavenplus\mojo\ShellMojo.java 157
protected Object setupConsole(final Class<?> consoleClass, final Class<?> bindingClass) throws InvocationTargetException, IllegalAccessException, InstantiationException {
        Object binding = invokeConstructor(findConstructor(bindingClass));
        initializeProperties();
        Method setVariable = findMethod(bindingClass, "setVariable", String.class, Object.class);
        if (bindPropertiesToSeparateVariables) {
            for (Object k : properties.keySet()) {
                invokeMethod(setVariable, binding, k, properties.get(k));
            }
        } else {
            if (groovyOlderThan(GROOVY_4_0_0_RC_1)) {
                invokeMethod(setVariable, binding, "properties", properties);
            } else {
                throw new IllegalArgumentException("properties is a read-only property in Groovy " + GROOVY_4_0_0_RC_1 + " and later.");
            }
        }
File Line
org\codehaus\gmavenplus\mojo\CompileMojo.java 68
org\codehaus\gmavenplus\mojo\GenerateStubsMojo.java 76
org\codehaus\gmavenplus\mojo\GroovyDocMojo.java 74
doCompile(getFiles(sources, false), project.getCompileClasspathElements(), outputDirectory);
        } catch (ClassNotFoundException e) {
            throw new MojoExecutionException("Unable to get a Groovy class from classpath (" + e.getMessage() + "). Do you have Groovy as a compile dependency in your project?", e);
        } catch (InvocationTargetException e) {
            throw new MojoExecutionException("Error occurred while calling a method on a Groovy class from classpath.", e);
        } catch (InstantiationException e) {
            throw new MojoExecutionException("Error occurred while instantiating a Groovy class from classpath.", e);
        } catch (IllegalAccessException e) {
            throw new MojoExecutionException("Unable to access a method on a Groovy class from classpath.", e);
        } catch (DependencyResolutionRequiredException e) {
            throw new MojoExecutionException("Compile dependencies weren't resolved.", e);
        } catch (MalformedURLException e) {
            throw new MojoExecutionException("Unable to add project compile dependencies to classpath.", e);
        }
    }

}
File Line
org\codehaus\gmavenplus\mojo\CompileTestsMojo.java 79
org\codehaus\gmavenplus\mojo\GenerateTestStubsMojo.java 86
org\codehaus\gmavenplus\mojo\GroovyDocTestsMojo.java 74
doCompile(getTestFiles(testSources, false), project.getTestClasspathElements(), testOutputDirectory);
        } catch (ClassNotFoundException e) {
            throw new MojoExecutionException("Unable to get a Groovy class from classpath (" + e.getMessage() + "). Do you have Groovy as a compile dependency in your project?", e);
        } catch (InvocationTargetException e) {
            throw new MojoExecutionException("Error occurred while calling a method on a Groovy class from classpath.", e);
        } catch (InstantiationException e) {
            throw new MojoExecutionException("Error occurred while instantiating a Groovy class from classpath.", e);
        } catch (IllegalAccessException e) {
            throw new MojoExecutionException("Unable to access a method on a Groovy class from classpath.", e);
        } catch (DependencyResolutionRequiredException e) {
            throw new MojoExecutionException("Test dependencies weren't resolved.", e);
        } catch (MalformedURLException e) {
            throw new MojoExecutionException("Unable to add project test dependencies to classpath.", e);
        }
    }

}
File Line
org\codehaus\gmavenplus\mojo\GroovyDocJarMojo.java 46
org\codehaus\gmavenplus\mojo\GroovyDocTestsJarMojo.java 46
public class GroovyDocJarMojo extends GroovyDocMojo {

    /**
     * Specifies the filename that will be used for the generated jar file. Please note that <code>-groovydoc</code>
     * will be appended to the file name.
     */
    @Parameter(property = "project.build.finalName")
    protected String finalName;

    /**
     * Specifies the directory where the generated jar file will be put.
     */
    @Parameter(property = "project.build.directory")
    protected String jarOutputDirectory;

    /**
     * The Jar archiver.
     */
    @Component(role = Archiver.class, hint = "jar")
    protected JarArchiver jarArchiver;

    /**
     * The archive configuration to use.
     * See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven Archiver Reference</a>.
     */
    @Parameter
    protected final MavenArchiveConfiguration archive = new MavenArchiveConfiguration();

    /**
     * Specifies whether to attach the generated artifact to the project helper.
     */
    @Parameter(property = "attach", defaultValue = "true")
    protected boolean attach;

    /**
     * Used for attaching the artifact in the project.
     */
    @Component
    private MavenProjectHelper projectHelper;

    /**
     * Path to the default MANIFEST file to use. It will be used if
     * <code>useDefaultManifestFile</code> is set to <code>true</code>.
     */
    @Parameter(defaultValue = "${project.build.outputDirectory}/META-INF/MANIFEST.MF", required = true, readonly = true)
    protected File defaultManifestFile;

    /**
     * Set this to <code>true</code> to enable the use of the <code>defaultManifestFile</code>.
     */
    @Parameter(defaultValue = "false")
    private boolean useDefaultManifestFile;

    /**
     * The classifier for the GroovyDoc jar.
     */
    @Parameter(defaultValue = "groovydoc")