public void populateArtifactInfo( ArtifactContext artifactContext ) throws IOException { ArtifactInfo ai = artifactContext.getArtifactInfo(); File artifactFile = artifactContext.getArtifact(); // TODO : olamy : supports only jars ? if ( artifactFile != null && artifactFile.isFile() && artifactFile.getName().endsWith( ".jar" ) ) { updateArtifactInfo( ai, artifactFile ); } }
@Override public ArtifactContext getArtifactContext(IndexingContext context, File file) { ArtifactContext ac = super.getArtifactContext(context, file); if (ac != null) { ArtifactInfo ai = ac.getArtifactInfo(); String fext = ai.fextension; if (fext != null) { return new ArtifactContext(ac.getPom(), ac.getArtifact(), ac.getMetadata(), new ArtifactInfo(ai.repository, ai.groupId, ai.artifactId, ai.version, null) { private String uinfo = null; @Override public String getUinfo() { }, ac.getGav());
private IndexOp index(final ArtifactContext ac) throws IOException { if (ac != null && ac.getGav() != null) { final Document d = ac.createDocument(context); if (d != null) { context.getIndexWriter().addDocument(d); return IndexOp.ADDED; } } return IndexOp.NOOP; }
@Override public void artifactError(final ArtifactContext ac, final Exception e) { Exception exception = e; if (ac.getPom() != null || ac.getArtifact() != null) { final StringBuilder sb = new StringBuilder("Found a problem while indexing"); if (ac.getArtifact() != null) { sb.append(" artifact '" + ac.getArtifact().getAbsolutePath() + "'"); } if (ac.getPom() != null) { sb.append(" pom '" + ac.getPom().getAbsolutePath() + "'"); } exception = new Exception(sb.toString(), e); } exceptions.add(exception); }
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.setFileExtension( getExtension( artifact, ac.getGav() ) );
private IndexOp update(final ArtifactContext ac) throws IOException { if (ac != null && ac.getGav() != null) { final Document d = ac.createDocument(context); if (d != null) { final Document old = getOldDocument(ac); if (old == null) { context.getIndexWriter().addDocument(d); return IndexOp.ADDED; } else if (!equals(d, old)) { context.getIndexWriter().updateDocument( new Term(ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo()), d); return IndexOp.UPDATED; } } } return IndexOp.NOOP; }
public Model getPomModel() File pom = getPom(); if ( pom != null && pom.isFile() ) else if ( getArtifact() != null && getArtifact().isFile() ) File artifact = getArtifact(); try ( ZipHandle handle = ZipFacade.getZipHandle( artifact ) ) "META-INF/maven/" + getGav().getGroupId() + "/" + getGav().getArtifactId() + "/pom.xml";
private Document getOldDocument(ArtifactContext ac) throws IOException { final TopDocs result = contextIndexSearcher.search( new TermQuery(new Term(ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo())), 2); if (result.totalHits == 1) { return contextIndexSearcher.doc(result.scoreDocs[0].doc); } return null; } }
@Override public void artifactDiscovered(ArtifactContext ac) { if (canceled.get()) { throw new Cancellation(); } count++; if (handle != null) { String label = ac.getArtifactInfo().groupId + ":" + ac.getArtifactInfo().artifactId + ":" + ac.getArtifactInfo().version; File art = ac.getArtifact(); if (art == null) { art = ac.getPom(); } if (art != null) { File d = art.getParentFile(); if (expectedDirs.contains(d)) { encounteredDirs.add(d); } } handle.progress(label, encounteredDirs.size()); } }
final ArtifactContext ac = new ArtifactContext(null, null, null, ai, ai.calculateGav()); if (contextPath == null || context.getGavCalculator().gavToPath(ac.getGav()).startsWith(contextPath)) { if (IndexOp.DELETED == remove(ac)) { deleted++;
public void artifactDiscovered( ArtifactContext ac ) String uinfo = ac.getArtifactInfo().getUinfo(); for ( Exception e : ac.getErrors() ) groups.add( ac.getArtifactInfo().getRootGroup() ); allGroups.add( ac.getArtifactInfo().getGroupId() );
doc.add( new Field( ArtifactInfo.UINFO, getArtifactInfo().getUinfo(), Store.YES, Index.NOT_ANALYZED ) ); addError( ex ); indexCreator.updateDocument( getArtifactInfo(), doc );
public void artifactDiscovered( ArtifactContext ac ) { count++; long t = System.currentTimeMillis(); ArtifactInfo ai = ac.getArtifactInfo(); if ( !quiet && debug && "maven-plugin".equals( ai.getPackaging() ) ) { System.err.printf( "Plugin: %s:%s:%s - %s %s\n", // ai.getGroupId(), ai.getArtifactId(), ai.getVersion(), ai.getPrefix(), "" + ai.getGoals() ); } if ( !quiet && ( debug || ( t - ts ) > 2000L ) ) { System.err.printf( " %6d %s\n", count, formatFile( ac.getPom() ) ); ts = t; } }
public void addArtifactToIndex( final File artifactFile, final ArtifactInfo artifactInfo ) throws IOException { getIndexer().addArtifactsToIndex( asList( new ArtifactContext( null, artifactFile, null, artifactInfo, null ) ), indexingContext ); }
ac = new ArtifactContext(null, null, null, ai, igav); log.debug("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.");
@Override public void artifactDiscovered( final ArtifactContext ac ) { try { LOGGER.debug( "Adding artifact gav: {}; ctx id: {}; idx dir: {}", new String[]{ ac.getGav().toString(), context.getId(), context.getIndexDirectory().toString() } ); getIndexer().addArtifactsToIndex( asList( ac ), context ); totalFiles++; } catch ( IOException ex ) { LOGGER.error( "Artifact index error", ex ); } } }
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.setFileExtension( getExtension( artifact, ac.getGav() ) );
public void update( IndexingContext context, ArtifactContext ac ) throws IOException { if ( ac != null && ac.getGav() != null ) { Document d = ac.createDocument( context ); if ( d != null ) { Document old = getOldDocument( context, ac ); if ( !equals( d, old ) ) { IndexWriter w = context.getIndexWriter(); w.updateDocument( new Term( ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo() ), d ); updateGroups( context, ac ); context.updateTimestamp(); } } } }
public Model getPomModel() File pom = getPom(); if ( pom != null && pom.isFile() ) else if ( getArtifact() != null && getArtifact().isFile() ) File artifact = getArtifact(); try ( ZipHandle handle = ZipFacade.getZipHandle( artifact ) ) "META-INF/maven/" + getGav().getGroupId() + "/" + getGav().getArtifactId() + "/pom.xml";
private IndexOp remove(final ArtifactContext ac) throws IOException { if (ac != null) { final String uinfo = ac.getArtifactInfo().getUinfo(); // add artifact deletion marker final 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)); return IndexOp.DELETED; } return IndexOp.NOOP; }