Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from netceler/JENKINS-45887
JENKINS-45887 : Fix TU and avoid workspace scan if not necessary
- Loading branch information
Showing
6 changed files
with
96 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...gin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/DependenciesLister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.jenkinsci.plugins.pipeline.maven.publishers; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor; | ||
import org.jenkinsci.plugins.pipeline.maven.util.XmlUtils; | ||
import org.w3c.dom.Element; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* List dependencies from the spy log. | ||
* @author <a href="mailto:cleclerc@cloudbees.com">Cyrille Le Clerc</a> | ||
*/ | ||
public class DependenciesLister { | ||
|
||
/** | ||
* @param mavenSpyLogs Root XML element | ||
* @return list of {@link MavenSpyLogProcessor.MavenArtifact} | ||
*/ | ||
@Nonnull | ||
public static List<MavenSpyLogProcessor.MavenDependency> listDependencies(final Element mavenSpyLogs, | ||
final Logger logger) { | ||
|
||
final List<MavenSpyLogProcessor.MavenDependency> result = new ArrayList<>(); | ||
|
||
for (final Element dependencyResolutionResult : XmlUtils.getChildrenElements(mavenSpyLogs, | ||
"DependencyResolutionResult")) { | ||
final Element resolvedDependenciesElt = XmlUtils.getUniqueChildElementOrNull( | ||
dependencyResolutionResult, "resolvedDependencies"); | ||
|
||
if (resolvedDependenciesElt == null) { | ||
continue; | ||
} | ||
|
||
for (final Element dependencyElt : XmlUtils.getChildrenElements(resolvedDependenciesElt, | ||
"dependency")) { | ||
final MavenSpyLogProcessor.MavenDependency dependencyArtifact = XmlUtils.newMavenDependency( | ||
dependencyElt); | ||
|
||
final Element fileElt = XmlUtils.getUniqueChildElementOrNull(dependencyElt, "file"); | ||
if (fileElt == null || fileElt.getTextContent() == null | ||
|| fileElt.getTextContent().isEmpty()) { | ||
logger.log(Level.WARNING, "listDependencies: no associated file found for " | ||
+ dependencyArtifact + " in " + XmlUtils.toString(dependencyElt)); | ||
} else { | ||
dependencyArtifact.file = StringUtils.trim(fileElt.getTextContent()); | ||
} | ||
|
||
result.add(dependencyArtifact); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters