Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
Fix #3 Problem with docs jar not found if snapshotVersions element is…
Browse files Browse the repository at this point in the history
… missing in maven-metadata.xml
  • Loading branch information
stefan-sachs committed Jul 31, 2015
1 parent 81887d5 commit 8591af8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
public class ArtifactIdentifier {

private static final String SNAPSHOT_SUFFIX = "-SNAPSHOT";
public static final String SNAPSHOT_SUFFIX = "-SNAPSHOT";
private final String groupId;
private final String artifactId;
private final String version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,32 @@ private String getApidocFileNameFromMetadataXML(ArtifactIdentifier artifactIdent
}
}

// did not find a proper version, try to use "snapshot"
NodeList snapshotElements = rootElement.getElementsByTagName("snapshot");
if (snapshotElements.getLength() == 1) {
Node snapshotNode = snapshotElements.item(0);

NodeList childNodes = snapshotNode.getChildNodes();
Node timestampNode = null;
Node buildNumberNode = null;
for (int childIndex = 0; childIndex < childNodes.getLength(); childIndex++) {
Node _node = childNodes.item(childIndex);
String nodeName = _node.getNodeName();
if ("timestamp".equals(nodeName)) {
timestampNode = _node;
} else if ("buildNumber".equals(nodeName)) {
buildNumberNode = _node;
}
}

if (timestampNode != null && buildNumberNode != null) {
return artifactIdentifier.getArtifactId() + "-"
+ artifactIdentifier.getVersion().replace(ArtifactIdentifier.SNAPSHOT_SUFFIX, "") + "-"
+ timestampNode.getTextContent() + "-" + buildNumberNode.getTextContent() + "-"
+ artifactIdentifier.getClassifier() + ".jar";
}
}

} catch (SAXException | IOException | ParserConfigurationException e) {
throw new RepositoryException("Could not parse maven-metadata.xml for '" + artifactIdentifier + "'", e);
}
Expand Down

0 comments on commit 8591af8

Please sign in to comment.