CPD Results

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

Duplications

File Line
org/jomc/mojo/MainJavaClassesMojo.java 94
org/jomc/mojo/TestJavaClassesMojo.java 94
            final ModelContext context = this.getModelContext( this.getTestClassLoader() );
            final JavaClasses tool = this.getJavaClassesTool( context );
            final JAXBContext jaxbContext = context.createContext();
            final Marshaller marshaller = context.createMarshaller();
            final Unmarshaller unmarshaller = context.createUnmarshaller();
            final Schema schema = context.createSchema();

            marshaller.setSchema( schema );
            unmarshaller.setSchema( schema );

            final ModelValidationReport validationReport = context.validateModel( new JAXBSource(
                jaxbContext, new ObjectFactory().createModules( tool.getModules() ) ) );

            this.log( context, validationReport.isModelValid() ? Level.INFO : Level.SEVERE, validationReport );

            if ( validationReport.isModelValid() )
            {
                this.logSeparator( Level.INFO );
                final Module module = tool.getModules().getModule( this.getJomcTestModuleName() );

File Line
org/jomc/mojo/AbstractJomcMojo.java 323
org/jomc/mojo/AbstractJomcMojo.java 356
            for ( final Iterator it = this.getTestClasspathElements().iterator(); it.hasNext(); )
            {
                final String element = (String) it.next();
                final URL url = new File( element ).toURI().toURL();
                if ( !urls.contains( url ) )
                {
                    urls.add( url );
                    this.log( Level.FINE, getMessage( "classpathElement", url.toExternalForm() ), null );
                }
            }

            return new URLClassLoader( (URL[]) urls.toArray( new URL[ urls.size() ] ),
                                       Thread.currentThread().getContextClassLoader() );

        }
        catch ( final IOException e )
        {
            throw new MojoExecutionException( e.getMessage(), e );
        }
    }

    /**
     * Gets the project's runtime classpath elements.
     *
     * @return A set of classpath element strings.
     *
     * @throws MojoExecutionException if getting the classpath elements fails.
     */
    protected Set<String> getMainClasspathElements() throws MojoExecutionException

File Line
org/jomc/mojo/AbstractJomcMojo.java 395
org/jomc/mojo/AbstractJomcMojo.java 417
        for ( final Iterator it = this.getMavenProject().getTestArtifacts().iterator(); it.hasNext(); )
        {
            final Artifact a = (Artifact) it.next();

            if ( a.getFile() == null )
            {
                this.log( Level.WARNING, getMessage( "ignored", a.toString() ), null );
                continue;
            }

            if ( a.getGroupId().equals( "org.jomc" ) &&
                 ( a.getArtifactId().equals( "jomc-util" ) || a.getArtifactId().equals( "jomc-model" ) ||
                   a.getArtifactId().equals( "jomc-tools" ) ) )
            {
                continue;
            }

            final String element = a.getFile().getAbsolutePath();
            this.log( Level.FINE, getMessage( "testElement", element ), null );

File Line
org/jomc/mojo/ValidateMainJavaClassesMojo.java 84
org/jomc/mojo/ValidateTestJavaClassesMojo.java 84
            final ModelContext context = this.getModelContext( this.getTestClassLoader() );
            final JavaClasses tool = this.getJavaClassesTool( context );
            final JAXBContext jaxbContext = context.createContext();
            final Unmarshaller unmarshaller = context.createUnmarshaller();
            final Schema schema = context.createSchema();

            unmarshaller.setSchema( schema );

            final ModelValidationReport validationReport = context.validateModel( new JAXBSource(
                jaxbContext, new ObjectFactory().createModules( tool.getModules() ) ) );

            this.log( context, validationReport.isModelValid() ? Level.INFO : Level.SEVERE, validationReport );

            if ( validationReport.isModelValid() )
            {
                this.logSeparator( Level.INFO );
                final Module module = tool.getModules().getModule( this.getJomcTestModuleName() );

File Line
org/jomc/mojo/MainJavaClassesMojo.java 76
org/jomc/mojo/ValidateMainJavaClassesMojo.java 66
    public ValidateMainJavaClassesMojo()
    {
        super();
    }

    @Override
    protected void executeTool() throws Exception
    {
        if ( this.isClassProcessingEnabled() )
        {
            File classesDirectory = new File( this.getMavenProject().getBuild().getOutputDirectory() );
            if ( !classesDirectory.isAbsolute() )
            {
                classesDirectory = new File( this.getMavenProject().getBasedir(),
                                             this.getMavenProject().getBuild().getOutputDirectory() );

            }

            final ModelContext context = this.getModelContext( this.getMainClassLoader() );
            final JavaClasses tool = this.getJavaClassesTool( context );
            final JAXBContext jaxbContext = context.createContext();
            final Unmarshaller unmarshaller = context.createUnmarshaller();

File Line
org/jomc/mojo/TestJavaClassesMojo.java 101
org/jomc/mojo/ValidateTestJavaClassesMojo.java 88
            final Schema schema = context.createSchema();

            unmarshaller.setSchema( schema );

            final ModelValidationReport validationReport = context.validateModel( new JAXBSource(
                jaxbContext, new ObjectFactory().createModules( tool.getModules() ) ) );

            this.log( context, validationReport.isModelValid() ? Level.INFO : Level.SEVERE, validationReport );

            if ( validationReport.isModelValid() )
            {
                this.logSeparator( Level.INFO );
                final Module module = tool.getModules().getModule( this.getJomcTestModuleName() );

                if ( module != null )
                {
                    this.logProcessingModule( TOOLNAME, module.getName() );
                    tool.validateClasses( module, unmarshaller, classesDirectory );

File Line
org/jomc/mojo/MainJavaClassesMojo.java 101
org/jomc/mojo/ValidateMainJavaClassesMojo.java 88
            final Schema schema = context.createSchema();

            unmarshaller.setSchema( schema );

            final ModelValidationReport validationReport = context.validateModel(
                new JAXBSource( jaxbContext, new ObjectFactory().createModules( tool.getModules() ) ) );

            this.log( context, validationReport.isModelValid() ? Level.INFO : Level.SEVERE, validationReport );

            if ( validationReport.isModelValid() )
            {
                this.logSeparator( Level.INFO );
                final Module module = tool.getModules().getModule( this.getJomcModuleName() );

                if ( module != null )
                {
                    this.logProcessingModule( TOOLNAME, module.getName() );
                    tool.validateClasses( module, unmarshaller, classesDirectory );

File Line
org/jomc/mojo/TestJavaClassesMojo.java 82
org/jomc/mojo/ValidateTestJavaClassesMojo.java 72
    protected void executeTool() throws Exception
    {
        if ( this.isClassProcessingEnabled() )
        {
            File classesDirectory = new File( this.getMavenProject().getBuild().getTestOutputDirectory() );
            if ( !classesDirectory.isAbsolute() )
            {
                classesDirectory = new File( this.getMavenProject().getBasedir(),
                                             this.getMavenProject().getBuild().getTestOutputDirectory() );

            }

            final ModelContext context = this.getModelContext( this.getTestClassLoader() );
            final JavaClasses tool = this.getJavaClassesTool( context );
            final JAXBContext jaxbContext = context.createContext();
            final Unmarshaller unmarshaller = context.createUnmarshaller();

File Line
org/jomc/mojo/TestJavaClassesMojo.java 102
org/jomc/mojo/TestJavaSourcesMojo.java 85
            final JAXBContext jaxbContext = context.createContext();

            final ModelValidationReport validationReport = context.validateModel( new JAXBSource(
                jaxbContext, new ObjectFactory().createModules( tool.getModules() ) ) );

            this.log( context, validationReport.isModelValid() ? Level.INFO : Level.SEVERE, validationReport );

            if ( validationReport.isModelValid() )
            {
                this.logSeparator( Level.INFO );
                final Module module = tool.getModules().getModule( this.getJomcTestModuleName() );

                if ( module != null )
                {
                    this.logProcessingModule( TOOLNAME, module.getName() );
                    tool.manageSources( module, testSourceDirectory );

File Line
org/jomc/mojo/MainJavaClassesMojo.java 102
org/jomc/mojo/MainJavaSourcesMojo.java 85
            final JAXBContext jaxbContext = context.createContext();

            final ModelValidationReport validationReport = context.validateModel( new JAXBSource(
                jaxbContext, new ObjectFactory().createModules( tool.getModules() ) ) );

            this.log( context, validationReport.isModelValid() ? Level.INFO : Level.SEVERE, validationReport );

            if ( validationReport.isModelValid() )
            {
                this.logSeparator( Level.INFO );
                final Module module = tool.getModules().getModule( this.getJomcModuleName() );

                if ( module != null )
                {
                    this.logProcessingModule( TOOLNAME, module.getName() );
                    tool.manageSources( module, sourceDirectory );

File Line
org/jomc/mojo/MainJavaSourcesMojo.java 83
org/jomc/mojo/TestJavaSourcesMojo.java 83
            final ModelContext context = this.getModelContext( this.getTestClassLoader() );
            final JavaSources tool = this.getJavaSourcesTool( context );
            final JAXBContext jaxbContext = context.createContext();

            final ModelValidationReport validationReport = context.validateModel( new JAXBSource(
                jaxbContext, new ObjectFactory().createModules( tool.getModules() ) ) );

            this.log( context, validationReport.isModelValid() ? Level.INFO : Level.SEVERE, validationReport );

            if ( validationReport.isModelValid() )
            {
                this.logSeparator( Level.INFO );
                final Module module = tool.getModules().getModule( this.getJomcTestModuleName() );