public void populateArtifactInfo( ArtifactContext ac ) { File artifact = ac.getArtifact(); ArtifactInfo ai = ac.getArtifactInfo(); // we need the file to perform these checks, and those may be only JARs if ( artifact != null && MAVEN_PLUGIN_PACKAGING.equals( ai.packaging ) && artifact.getName().endsWith( ".jar" ) ) { // TODO: recheck, is the following true? "Maven plugins and Maven Archetypes can be only JARs?" // 1st, check for maven plugin checkMavenPlugin( ai, artifact ); } }
public void artifactDiscovered( ArtifactContext ac ) { count++; long t = System.currentTimeMillis(); ArtifactInfo ai = ac.getArtifactInfo(); if ( !quiet && debug && "maven-plugin".equals( ai.packaging ) ) { System.err.printf( "Plugin: %s:%s:%s - %s %s\n", // ai.groupId, ai.artifactId, ai.version, ai.prefix, "" + ai.goals ); } if ( !quiet && ( debug || ( t - ts ) > 2000L ) ) { System.err.printf( " %6d %s\n", count, formatFile( ac.getPom() ) ); ts = t; } }
public void index( IndexingContext context, ArtifactContext ac ) throws IOException { // skip artifacts not obeying repository layout (whether m1 or m2) if ( ac != null && ac.getGav() != null ) { Document d = ac.createDocument( context ); if ( d != null ) { context.getIndexWriter().addDocument( d ); context.updateTimestamp(); } } }
public void artifactError( ArtifactContext ac, Exception e ) { if ( !quiet ) { System.err.printf( "! %6d %s - %s\n", count, formatFile( ac.getPom() ), e.getMessage() ); System.err.printf( " %s\n", formatFile( ac.getArtifact() ) ); if ( debug ) { e.printStackTrace(); } } ts = System.currentTimeMillis(); }
public void populateArtifactInfo( ArtifactContext ac ) File artifact = ac.getArtifact(); File pom = ac.getPom(); ArtifactInfo ai = ac.getArtifactInfo(); Model model = ac.getPomModel(); ac.addError( e ); ai.fextension = getExtension( artifact, ac.getGav() );
private void updateGroups( IndexingContext context, ArtifactContext ac ) throws IOException { String rootGroup = ac.getArtifactInfo().getRootGroup(); Set<String> rootGroups = context.getRootGroups(); if ( !rootGroups.contains( rootGroup ) ) { rootGroups.add( rootGroup ); context.setRootGroups( rootGroups ); } Set<String> allGroups = context.getAllGroups(); if ( !allGroups.contains( ac.getArtifactInfo().groupId ) ) { allGroups.add( ac.getArtifactInfo().groupId ); context.setAllGroups( allGroups ); } }
public void update( IndexingContext context, ArtifactContext ac ) throws IOException { Document d = ac.createDocument( context ); if ( d != null ) { IndexWriter w = context.getIndexWriter(); w.updateDocument( new Term( ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo() ), d ); updateGroups( context, ac ); w.commit(); context.updateTimestamp(); } }
doc.add( new Field( ArtifactInfo.UINFO, getArtifactInfo().getUinfo(), Store.YES, Index.UN_TOKENIZED ) ); addError( ex ); indexCreator.updateDocument( getArtifactInfo(), doc );
ac = new ArtifactContext( null, null, null, ai, gav ); "NOT deleting artifact " + ac.getArtifactInfo().groupId + ":" + ac.getArtifactInfo().artifactId + ":" + ac.getArtifactInfo().version + " from index (DELETE), since it is a timestamped snapshot and more builds exists." );
public void artifactDiscovered( ArtifactContext ac ) String uinfo = ac.getArtifactInfo().getUinfo(); for ( Exception e : ac.getErrors() ) groups.add( ac.getArtifactInfo().getRootGroup() ); allGroups.add( ac.getArtifactInfo().groupId );
ArtifactContext ac = new ArtifactContext( null, null, null, ai, ai.calculateGav() );
public void remove( IndexingContext context, ArtifactContext ac ) throws IOException { if ( ac != null ) { String uinfo = ac.getArtifactInfo().getUinfo(); // add artifact deletion marker Document doc = new Document(); doc.add( new Field( ArtifactInfo.DELETED, uinfo, Field.Store.YES, Field.Index.NO ) ); doc.add( new Field( ArtifactInfo.LAST_MODIFIED, // Long.toString( System.currentTimeMillis() ), Field.Store.YES, Field.Index.NO ) ); IndexWriter w = context.getIndexWriter(); w.addDocument( doc ); w.deleteDocuments( new Term( ArtifactInfo.UINFO, uinfo ) ); w.commit(); context.updateTimestamp(); } }
public void artifactError(ArtifactContext ac, Exception e) { if (debug) { writer.printf("! %6d %s - %s\n", count, formatFile(ac.getPom()), e.getMessage()); writer.printf(" %s\n", formatFile(ac.getArtifact())); e.printStackTrace(writer); } }
return new ArtifactContext( pom, artifact, metadata, ai, gav );
public void populateArtifactInfo( ArtifactContext artifactContext ) throws IOException { ArtifactInfo ai = artifactContext.getArtifactInfo(); File artifactFile = artifactContext.getArtifact(); if ( artifactFile != null && artifactFile.exists() && artifactFile.getName().endsWith( ".jar" ) ) { updateArtifactInfo( ai, artifactFile ); } }
public void updateDocument(ArtifactIndexingContext context, Document doc) { ArtifactInfo ai = context.getArtifactContext().getArtifactInfo(); if (ai.classifier != null) { //don't process items with classifier return; } try { MavenProject mp = RepositoryUtil.readMavenProject(ai.groupId, ai.artifactId, ai.version, repository); if (mp != null) { List<Dependency> dependencies = mp.getDependencies(); for (Dependency d : dependencies) { doc.add(new Field(NB_DEPENDENCY_GROUP, d.getGroupId(), Field.Store.NO, Field.Index.UN_TOKENIZED)); doc.add(new Field(NB_DEPENDENCY_ARTIFACT, d.getArtifactId(), Field.Store.NO, Field.Index.UN_TOKENIZED)); doc.add(new Field(NB_DEPENDENCY_VERSION, d.getVersion(), Field.Store.NO, Field.Index.UN_TOKENIZED)); } } } catch (InvalidArtifactRTException ex) { ex.printStackTrace(); } }
public void artifactDiscovered(ArtifactContext ac) { count++; ArtifactInfo ai = ac.getArtifactInfo(); if (debug) { if ("maven-plugin".equals(ai.packaging)) { writer.printf("Plugin: %s:%s:%s - %s %s\n", // ai.groupId, ai.artifactId, ai.version, ai.prefix, "" + ai.goals); } // ArtifactInfo ai = ac.getArtifactInfo(); writer.printf(" %6d %s\n", count, formatFile(ac.getPom())); } handle.progress(ac.getArtifactInfo().groupId + ":" + ac.getArtifactInfo().artifactId + ":" + ac.getArtifactInfo().version); }
public Model getPomModel() if ( getPom() != null && getPom().exists() ) return new ModelReader().readModel( new FileInputStream( getPom() ) ); else if ( getArtifact() != null ) jar = new ZipFile( getArtifact() );
public void populateArtifactInfo( ArtifactContext ac ) { File artifact = ac.getArtifact(); ArtifactInfo ai = ac.getArtifactInfo(); // we need the file to perform these checks, and those may be only JARs if ( artifact != null && !MAVEN_ARCHETYPE_PACKAGING.equals( ai.packaging ) && artifact.getName().endsWith( ".jar" ) ) { // TODO: recheck, is the following true? "Maven plugins and Maven Archetypes can be only JARs?" // check for maven archetype, since Archetypes seems to not have consistent packaging, // and depending on the contents of the JAR, this call will override the packaging to "maven-archetype"! checkMavenArchetype( ai, artifact ); } }
String uinfo = ac.getArtifactInfo().getUinfo(); TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 ); if ( d.totalHits == 0 ) log.debug( "Adding artifact '" + ac.getArtifactInfo() + "' to index.." ); indexerEngine.index( context, ac ); context.getIndexWriter().commit(); log.debug( "Updating artifact '" + ac.getArtifactInfo() + "' in index.." ); indexerEngine.update( context, ac ); context.getIndexWriter().commit(); log.debug( "Removing artifact '" + ac.getArtifactInfo() + "' from index.." ); indexerEngine.remove( context, ac ); context.getIndexWriter().commit();