Package org.apache.maven.index

Examples of org.apache.maven.index.ArtifactContext


        File pom = new File( getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom" );

        ArtifactInfo artifactInfo = new ArtifactInfo( "test", "aopalliance", "aopalliance", "1.0", null );

        ArtifactContext artifactContext = new ArtifactContext( pom, artifact, null, artifactInfo, null );

        indexCreator.populateArtifactInfo( artifactContext );

        assertNotNull( "Classes should not be null", artifactContext.getArtifactInfo().classNames );
    }
View Full Code Here


        File pom = new File( getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom" );

        ArtifactInfo artifactInfo = new ArtifactInfo( "test", "aopalliance", "aopalliance", "1.0", null );

        ArtifactContext artifactContext = new ArtifactContext( pom, artifact, null, artifactInfo, null );

        indexCreator.populateArtifactInfo( artifactContext );

        assertNull( "Classes should be null", artifactContext.getArtifactInfo().classNames );
    }
View Full Code Here

                "src/test/mindexer-35/org/apache/maven/indexer/test/sample-war/1.0-SNAPSHOT/sample-war-1.0-SNAPSHOT.pom" );

        ArtifactInfo artifactInfo =
            new ArtifactInfo( "test", "org.apache.maven.indexer.test", "sample-war", "1.0-SNAPSHOT", null );

        ArtifactContext artifactContext = new ArtifactContext( pom, artifact, null, artifactInfo, null );

        indexCreator.populateArtifactInfo( artifactContext );

        assertTrue( "Classes should contain WebappClass",
            artifactContext.getArtifactInfo().classNames.contains( "WebappClass" ) );
        assertEquals( "WebappClass should have proper package",
            "/org/apache/maven/indexer/samples/webapp/WebappClass", artifactContext.getArtifactInfo().classNames );
    }
View Full Code Here

            new ArtifactInfo( "test", "org.apache.maven.plugins", "maven-dependency-plugin", "2.0", null );

        artifactInfo.packaging = "maven-plugin";
        artifactInfo.fextension = "jar";

        ArtifactContext artifactContext = new ArtifactContext( pom, artifact, null, artifactInfo, null );

        indexCreator.populateArtifactInfo( artifactContext );

        assertEquals( "dependency", artifactContext.getArtifactInfo().prefix );

        List<String> goals = new ArrayList<String>( 16 );
        goals.add( "analyze-dep-mgt" );
        goals.add( "analyze" );
        goals.add( "analyze-only" );
        goals.add( "analyze-report" );
        goals.add( "build-classpath" );
        goals.add( "copy-dependencies" );
        goals.add( "copy" );
        goals.add( "unpack" );
        goals.add( "list" );
        goals.add( "purge-local-repository" );
        goals.add( "go-offline" );
        goals.add( "resolve" );
        goals.add( "sources" );
        goals.add( "resolve-plugins" );
        goals.add( "tree" );
        goals.add( "unpack-dependencies" );

        assertEquals( goals, artifactContext.getArtifactInfo().goals );

    }
View Full Code Here

                             "src/test/repo-with-osgi/org/apache/karaf/features/org.apache.karaf.features.command/2.2.2/org.apache.karaf.features.command-2.2.2.pom" );

        ArtifactInfo artifactInfo =
            new ArtifactInfo( "test", "org.apache.karaf.features", "org.apache.karaf.features.command", "2.2.2", null );

        ArtifactContext artifactContext = new ArtifactContext( pom, artifact, null, artifactInfo, null );

        indexCreator.populateArtifactInfo( artifactContext );

        assertNotNull( "bundleSymbolicName", artifactContext.getArtifactInfo().bundleSymbolicName );

        assertNotNull( "bundleVersion", artifactContext.getArtifactInfo().bundleVersion );

        assertNotNull( "bundleExportPackage", artifactContext.getArtifactInfo().bundleExportPackage );

        assertEquals( "org.apache.karaf.features.command", artifactContext.getArtifactInfo().bundleSymbolicName );

        assertEquals( "2.2.2", artifactContext.getArtifactInfo().bundleVersion );

        assertEquals(
            "org.apache.karaf.features.command.completers;uses:=\"org.apache.karaf.features,org.apache.karaf.shell.console,org.apache.karaf.shell.console.completer\";version=\"2.2.2\",org.apache.karaf.features.command;uses:=\"org.apache.felix.gogo.commands,org.apache.karaf.features,org.apache.karaf.shell.console,org.osgi.framework,org.apache.felix.service.command\";version=\"2.2.2\"",
            artifactContext.getArtifactInfo().bundleExportPackage );

        ArtifactInfo ai = artifactContext.getArtifactInfo();

        assertEquals( "This bundle provides the Karaf shell commands to manipulate features.", ai.bundleDescription );
        assertEquals( "Apache Karaf :: Features :: Command", ai.bundleName );
        assertEquals( "http://www.apache.org/licenses/LICENSE-2.0.txt", ai.bundleLicense );
        assertEquals( "http://www.apache.org/", ai.bundleDocUrl );
View Full Code Here

    public void testContextProducer()
    {
        final File pomFile =
            getTestFile( "src/test/repo/ch/marcus-schulte/maven/hivedoc-plugin/1.0.0/hivedoc-plugin-1.0.0.pom" );

        final ArtifactContext ac = artifactContextProducer.getArtifactContext( context, pomFile );

        assertTrue( "Artifact file was not found!", ac.getArtifact() != null );
        assertTrue( "Artifact file was not found!", ac.getArtifact().exists() );
    }
View Full Code Here

        File metadata = null;
        ArtifactInfo artifactInfo = new ArtifactInfo( repositoryId, groupId, artifactId, version, classifier );
        Gav gav =
            new Gav( groupId, artifactId, version, classifier, "jar", null, null, artifact.getName(), false,
                null, false, null );
        return new ArtifactContext( pomFile, artifact, metadata, artifactInfo, gav );
    }
View Full Code Here

            }

            try
            {
                File artifactFile = indexingTask.getResourceFile();
                ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

                if ( ac != null )
                {
                    if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
                    {
                        //IndexSearcher s = context.getIndexSearcher();
                        //String uinfo = ac.getArtifactInfo().getUinfo();
                        //TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 );

                        BooleanQuery q = new BooleanQuery();
                        q.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression(
                            ac.getArtifactInfo().groupId ) ), BooleanClause.Occur.MUST );
                        q.add( nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression(
                            ac.getArtifactInfo().artifactId ) ), BooleanClause.Occur.MUST );
                        q.add( nexusIndexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
                            ac.getArtifactInfo().version ) ), BooleanClause.Occur.MUST );
                        if ( ac.getArtifactInfo().classifier != null )
                        {
                            q.add( nexusIndexer.constructQuery( MAVEN.CLASSIFIER, new SourcedSearchExpression(
                                ac.getArtifactInfo().classifier ) ), BooleanClause.Occur.MUST );
                        }
                        if ( ac.getArtifactInfo().packaging != null )
                        {
                            q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                        }
                        FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                        FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                        if ( flatSearchResponse.getResults().isEmpty() )
                        {
                            log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                            nexusIndexer.addArtifactToIndex( ac, context );
                        }
                        else
                        {
                            log.debug( "Updating artifact '{}' in index..", ac.getArtifactInfo() );
                            // TODO check if update exists !!
                            nexusIndexer.deleteArtifactFromIndex( ac, context );
                            nexusIndexer.addArtifactToIndex( ac, context );
                        }

                        context.updateTimestamp();

                        // close the context if not a repo scan request
                        if ( !indexingTask.isExecuteOnEntireRepo() )
                        {
                            log.debug( "Finishing indexing task on resource file : {}",
                                       indexingTask.getResourceFile().getPath() );
                            finishIndexingTask( indexingTask, repository, context );
                        }
                    }
                    else
                    {
                        log.debug( "Removing artifact '{}' from index..", ac.getArtifactInfo() );
                        nexusIndexer.deleteArtifactFromIndex( ac, context );
                    }
                }
            }
            catch ( IOException e )
View Full Code Here

        context.getIndexWriter().setMaxBufferedDocs( -1 );
        context.getIndexWriter().setRAMBufferSizeMB( 1 );
        for ( File artifactFile : filesToBeIndexed )
        {
            assertTrue( "file not exists " + artifactFile.getPath(), artifactFile.exists() );
            ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
            nexusIndexer.addArtifactToIndex( ac, context );
            context.updateTimestamp( true );
        }

        if ( scan )
View Full Code Here

                {
                    log.debug( "no artifact pass in indexing task so skip it" );
                }
                else
                {
                    ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

                    if ( ac != null )
                    {
                        // MRM-1779 pom must be indexed too
                        // TODO make that configurable?
                        if ( artifactFile.getPath().endsWith( ".pom" ) )
                        {
                            ac.getArtifactInfo().fextension = "pom";
                            ac.getArtifactInfo().packaging = "pom";
                            ac.getArtifactInfo().classifier = "pom";
                        }
                        if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
                        {
                            //IndexSearcher s = context.getIndexSearcher();
                            //String uinfo = ac.getArtifactInfo().getUinfo();
                            //TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 );

                            BooleanQuery q = new BooleanQuery();
                            q.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().groupId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().artifactId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
                                ac.getArtifactInfo().version ) ), BooleanClause.Occur.MUST );
                            if ( ac.getArtifactInfo().classifier != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.CLASSIFIER, new SourcedSearchExpression(
                                    ac.getArtifactInfo().classifier ) ), BooleanClause.Occur.MUST );
                            }
                            if ( ac.getArtifactInfo().packaging != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                    ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                            }
                            FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                            FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                            if ( flatSearchResponse.getResults().isEmpty() )
                            {
                                log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }
                            else
                            {
                                log.debug( "Updating artifact '{}' in index..", ac.getArtifactInfo() );
                                // TODO check if update exists !!
                                nexusIndexer.deleteArtifactFromIndex( ac, context );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }

                            context.updateTimestamp();
                            context.commit();


                        }
                        else
                        {
                            log.debug( "Removing artifact '{}' from index..", ac.getArtifactInfo() );
                            nexusIndexer.deleteArtifactFromIndex( ac, context );
                        }
                    }
                }
                // close the context if not a repo scan request
View Full Code Here

TOP

Related Classes of org.apache.maven.index.ArtifactContext

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.