public GAV( ProjectVersionRef pvr ) { groupId = pvr.getGroupId(); artifactId = pvr.getArtifactId(); version = pvr.getVersionString(); } }
private boolean addGA( final ProjectVersionRef ref ) { final ProjectRef pr = ref.asProjectRef(); Set<ProjectVersionRef> refs = byGA.get( pr ); if ( refs == null ) { refs = new HashSet<ProjectVersionRef>(); byGA.put( pr, refs ); } return refs.add( ref ); }
public static Set<ArtifactRef> collectArtifactReferences( final Collection<ProjectRelationship<?, ?>> rels, final boolean includePomArtifacts ) { final Set<ArtifactRef> artifacts = new HashSet<ArtifactRef>(); for ( final ProjectRelationship<?, ?> rel : rels ) { // if ( !( rel instanceof DependencyRelationship ) ) // { // continue; // } if ( includePomArtifacts ) { final ProjectVersionRef pvr = rel.getDeclaring() .asProjectVersionRef(); artifacts.add( pvr.asPomArtifact() ); } final ArtifactRef tar = rel.getTargetArtifact(); artifacts.add( tar ); if ( includePomArtifacts ) { artifacts.add( tar.asPomArtifact() ); } } return artifacts; }
public SimpleArtifactRef( final ProjectVersionRef ref, final String type, final String classifier ) { super( ref.getGroupId(), ref.getArtifactId(), ref.getVersionSpecRaw(), ref.getVersionStringRaw() ); this.tc = new SimpleTypeAndClassifier( type, classifier ); }
@Override public int compare( final ProjectVersionRef f, final ProjectVersionRef s ) { final int comp = f.compareTo( s ); // this compares groupId and artifactId ONLY if ( comp == 0 ) { final VersionSpec fs = f.getVersionSpec(); final VersionSpec ss = s.getVersionSpec(); return fs.compareTo( ss ); } return comp; }
@Override public boolean containsProject( final ViewParams params, final ProjectVersionRef ref ) { return graph.containsVertex( ref.asProjectVersionRef() ) && !incompleteSubgraphs.contains( ref.asProjectVersionRef() ); }
model.setGroupId( pomCoord.getGroupId() ); model.setArtifactId( pomCoord.getArtifactId() ); model.setVersion( pomCoord.getVersionSpec().renderStandard() ); model.setPackaging( "pom" ); model.setDescription( "Generated by Cartographer at " + new Date() ); if ( recipe.isGraphToManagedDeps() ) model.setName( pomCoord.getArtifactId() + ":: Bill of Materials" ); dm = new DependencyManagement(); model.setDependencyManagement( dm ); model.setName( pomCoord.getArtifactId() ); dm = null;
public static void toNodeProperties( final ProjectVersionRef ref, final Node node, final boolean connected ) { Logger logger = LoggerFactory.getLogger( Conversions.class ); logger.debug( "Adding {} (type: {}) to node: {}", ref, ref.getClass().getSimpleName(), node ); if ( !( ref instanceof NeoProjectVersionRef ) || ( (NeoProjectVersionRef) ref ).isDirty() ) { final String g = ref.getGroupId(); final String a = ref.getArtifactId(); final String v = ref.getVersionString(); if ( empty( g ) || empty( a ) || empty( v ) ) { throw new IllegalArgumentException( String.format( "GAV cannot contain nulls: %s:%s:%s", g, a, v ) ); } node.setProperty( ARTIFACT_ID, a ); node.setProperty( GROUP_ID, g ); logger.debug( "Setting property: {} with value: {} for node: {}", VERSION, v, node.getId() ); node.setProperty( VERSION, v ); node.setProperty( GAV, ref.toString() ); } node.setProperty( NODE_TYPE, NodeType.PROJECT.name() ); if ( ref.isVariableVersion() ) { node.setProperty( VARIABLE, true ); } markConnected( node, connected ); // // logger.debug( "groupId of {} is:\nNeoIdentityUtils: {}\nConversions: {}\nDirect access: {}", node, // NeoIdentityUtils.getStringProperty( node, GROUP_ID, null, null ), // getStringProperty( GROUP_ID, node ), node.hasProperty( GROUP_ID ) ? node.getProperty( GROUP_ID ) : null ); }
final ProjectVersionRef pvr = orig.asProjectVersionRef(); final ProjectRef r = rel.getDeclaring() .asProjectRef(); ProjectRefCollection prc = projects.get( r ); if ( prc == null ) prc.addArtifactRef( pvr.asPomArtifact() );
public static Map<ProjectRef, ProjectRefCollection> collectProjectReferences( final Map<ProjectVersionRef, Map<ArtifactRef, ConcreteResource>> refMap ) { final Map<ProjectRef, ProjectRefCollection> projects = new HashMap<>(); for ( final Map.Entry<ProjectVersionRef, Map<ArtifactRef, ConcreteResource>> projectEntry : refMap.entrySet() ) { final ProjectVersionRef pvr = projectEntry.getKey(); final ProjectRef r = pvr.asProjectRef(); ProjectRefCollection prc = projects.get( r ); if ( prc == null ) { prc = new ProjectRefCollection(); projects.put( r, prc ); } prc.addVersionRef( pvr ); prc.addArtifactRef( pvr.asPomArtifact() ); for ( final ArtifactRef ar : projectEntry.getValue() .keySet() ) { prc.addArtifactRef( ar ); } } return projects; }
private VersionSpec generateVersionSpec( final Set<ProjectVersionRef> refs, final boolean generateVersionRanges ) { final List<VersionSpec> versions = new ArrayList<>(); for ( final ProjectVersionRef ref : refs ) { final VersionSpec spec = ref.getVersionSpec(); versions.add( spec ); } Collections.sort( versions ); if ( !generateVersionRanges || versions.size() == 1 ) { return versions.get( 0 ); } return new CompoundVersionSpec( null, versions ); }
/** * This method will generate maven-metadata for * @param key * @param pomFile * @param p * @throws IOException */ private void initSnapshot(ProjectVersionRef key, Path pomFile, Path p) throws IOException { Path dir = p.getParent(); Path metadata = dir.resolve("maven-metadata.xml"); if(Files.exists(metadata)){ throw new UnsupportedOperationException("Merging of metadata is not supported yet. Conflicting metadata: " + metadata); } try (BufferedReader reader = new BufferedReader(new InputStreamReader( LocalRepo.class.getResourceAsStream("/template/maven-metadata.xml")))) { Stream<String> lines = reader.lines() .map(l -> l.replace("${groupId}", key.getGroupId())) .map(l -> l.replace("${artifactId}", key.getGroupId())) .map(l -> l.replace("${version}", key.getVersionString().replace("-SNAPSHOT", ""))); Files.write(metadata, (Iterable<String>) lines::iterator); Path newPomFile = dir.resolve(p.getFileName().toString().replace("-SNAPSHOT.pom", SUFFIX)); Files.copy(pomFile, newPomFile); } } }
.getId(), type.name(), target.getGroupId(), target.getArtifactId() );
if ( other.getVersionSpec() != null ) else if ( !getVersionSpec().equals( other.getVersionSpec() ) ) if ( other.getVersionString() != null ) else if ( !getVersionString().equals( other.getVersionString() ) )
private Node newProjectNode( final ProjectVersionRef ref ) { final Node node = graph.createNode(); toNodeProperties( ref, node, false ); final String gav = ref.asProjectVersionRef() .toString(); graph.index() .forNodes( BY_GAV_IDX ) .add( node, GAV, gav ); graph.index() .forNodes( BY_GA_IDX ) .add( node, GA, ref.asProjectRef() .toString() ); graph.index() .forNodes( MISSING_NODES_IDX ) .add( node, GAV, gav ); if ( ref.isVariableVersion() ) { // logger.info( "Adding {} to variable-nodes index.", ref ); graph.index() .forNodes( VARIABLE_NODES_IDX ) .add( node, GAV, gav ); } // logger.info( "Created project node: {} with id: {}", ref, node.getId() ); return node; }
@Override public ArtifactRef getTargetArtifact() { return getTarget().asPomArtifact(); }
try if ( !ref.isSpecificVersion() ) final ArtifactRef pomRef = specific.asPomArtifact();
.asProjectVersionRef(); if ( target.isVariableVersion() || !target.getVersionSpec() .isSingle() ) graph.addVertex( target.asProjectVersionRef() ); addGA( target ); graph.addEdge( rel, rel.getDeclaring(), target.asProjectVersionRef() ); .asProjectVersionRef() );
.asProjectVersionRef(); for ( final ProjectVersionRef ref : new ProjectVersionRef[] { declaring, target } ) final IndexHits<Node> hits = index.get( GAV, ref.asProjectVersionRef() .toString() ); if ( !hits.hasNext() ) logger.debug( "Using existing project node: {} for: {}", nodes[i], ref.asProjectVersionRef() ); .getId(), rel.getType() .name(), rel.getTarget() .getGroupId(), rel.getTarget() .getArtifactId() ) );
@Override public ProjectVersionRef getManagedTargetFor( final ProjectVersionRef target, final GraphPath<?> path, final RelationshipType type ) { if ( path == null ) { return null; } if ( !( path instanceof JungGraphPath ) ) { throw new IllegalArgumentException( "Cannot process GraphPath's from other implementations. (Non-Jung GraphPath detected: " + path + ")" ); } final ProjectRef targetGA = target.asProjectRef(); final JungGraphPath jungpath = (JungGraphPath) path; for ( final ProjectRelationship<?, ?> ref : jungpath ) { final Collection<ProjectRelationship<?, ?>> outEdges = graph.getOutEdges( ref.getDeclaring() ); for ( final ProjectRelationship<?, ?> edge : outEdges ) { if ( edge.isManaged() && type == edge.getType() && targetGA.equals( edge.getTarget() ) ) { return edge.getTarget() .asProjectVersionRef(); } } } return null; }