Skip to content

Commit dbc1378

Browse files
committed
Add version number to Java artifact
1 parent 6915989 commit dbc1378

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Set property "version" on Artifact nodes to what is specified in the Maven POM
2+
3+
MATCH (artifact:Java:Artifact)-[:CONTAINS]-(pom:Maven:Pom)
4+
MATCH (pom)-[:HAS_ROOT_ELEMENT]->(pomProject:Element{name:'project'})
5+
OPTIONAL MATCH (pomProject)-[:HAS_ELEMENT]->(:Element{name:'version'})-[:HAS_TEXT]->(versionValue:Text)
6+
OPTIONAL MATCH (pomProject)-[:HAS_ELEMENT]->(:Element{name:'parent'})
7+
-[:HAS_ELEMENT]->(:Element{name:'version'})-[:HAS_TEXT]->(parentVersionValue:Text)
8+
WITH *, artifact, coalesce(versionValue.value, parentVersionValue.value) AS versionNumber
9+
WHERE versionNumber IS NOT NULL
10+
SET artifact.version = versionNumber
11+
RETURN count(DISTINCT artifact.fileName) AS numberOfUpdatedArtifacts
12+
// Debugging
13+
// RETURN artifact.name, versionNumber, versionValue.value, parentVersionValue.value
14+
// LIMIT 25

scripts/prepareAnalysis.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ execute_cypher "${TYPES_CYPHER_DIR}/Label_resolved_duplicate_types.cypher"
117117
execute_cypher "${EXTERNAL_DEPENDENCIES_CYPHER_DIR}/Remove_external_type_and_annotation_labels.cypher"
118118
execute_cypher "${EXTERNAL_DEPENDENCIES_CYPHER_DIR}/Label_external_types_and_annotations.cypher"
119119

120-
# Preparation - Add Java Artifact node properties "incomingDependencies" and "outgoingDependencies"
120+
# Preparation - Add Java Artifact node properties "incomingDependencies", "outgoingDependencies" and "version"
121121
execute_cypher_summarized "${ARTIFACT_DEPENDENCIES_CYPHER_DIR}/Incoming_Java_Artifact_Dependencies.cypher"
122122
execute_cypher_summarized "${ARTIFACT_DEPENDENCIES_CYPHER_DIR}/Outgoing_Java_Artifact_Dependencies.cypher"
123+
execute_cypher_summarized "${ARTIFACT_DEPENDENCIES_CYPHER_DIR}/Set_maven_artifact_version.cypher"
123124

124125
# Preparation - Add Java Type node properties "incomingDependencies" and "outgoingDependencies"
125126
execute_cypher_summarized "${METRICS_CYPHER_DIR}/Set_Incoming_Java_Type_Dependencies.cypher"

0 commit comments

Comments
 (0)