Skip to content

Commit

Permalink
Bump maven-dep-tree to 1.1.0 (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi authored Jan 7, 2024
1 parent acbd551 commit 24f553d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion buildscripts/download-jars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Once you have updated the versions mentioned below, please execute this script from the root directory of the jfrog-cli-core to ensure the JAR files are updated.
GRADLE_DEP_TREE_VERSION="3.0.1"
# Changing this version also requires a change in mavenDepTreeVersion within xray/commands/audit/sca/java/mvn.go.
MAVEN_DEP_TREE_VERSION="1.0.2"
MAVEN_DEP_TREE_VERSION="1.1.0"

curl -fL https://releases.jfrog.io/artifactory/oss-release-local/com/jfrog/gradle-dep-tree/${GRADLE_DEP_TREE_VERSION}/gradle-dep-tree-${GRADLE_DEP_TREE_VERSION}.jar -o xray/commands/audit/sca/java/resources/gradle-dep-tree.jar
curl -fL https://releases.jfrog.io/artifactory/oss-release-local/com/jfrog/maven-dep-tree/${MAVEN_DEP_TREE_VERSION}/maven-dep-tree-${MAVEN_DEP_TREE_VERSION}.jar -o xray/commands/audit/sca/java/resources/maven-dep-tree.jar
25 changes: 6 additions & 19 deletions xray/commands/audit/sca/java/mvn.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
mavenDepTreeJarFile = "maven-dep-tree.jar"
mavenDepTreeOutputFile = "mavendeptree.out"
// Changing this version also requires a change in MAVEN_DEP_TREE_VERSION within buildscripts/download_jars.sh
mavenDepTreeVersion = "1.0.2"
mavenDepTreeVersion = "1.1.0"
settingsXmlFile = "settings.xml"
)

Expand Down Expand Up @@ -113,35 +113,22 @@ func GetMavenPluginInstallationGoals(pluginPath string) []string {
}

func (mdt *MavenDepTreeManager) execMavenDepTree(depTreeExecDir string) (string, error) {
if mdt.cmdName == Tree {
return mdt.runTreeCmd(depTreeExecDir)
}
return mdt.runProjectsCmd()
depTreeOutputPath := filepath.Join(depTreeExecDir, mavenDepTreeOutputFile)
goals := []string{"com.jfrog:maven-dep-tree:" + mavenDepTreeVersion + ":" + string(mdt.cmdName), "-DdepsTreeOutputFile=" + depTreeOutputPath, "-B"}
return mdt.run(goals, depTreeOutputPath)
}

func (mdt *MavenDepTreeManager) runTreeCmd(depTreeExecDir string) (string, error) {
mavenDepTreePath := filepath.Join(depTreeExecDir, mavenDepTreeOutputFile)
goals := []string{"com.jfrog:maven-dep-tree:" + mavenDepTreeVersion + ":" + string(Tree), "-DdepsTreeOutputFile=" + mavenDepTreePath, "-B"}
func (mdt *MavenDepTreeManager) run(goals []string, depTreeOutputPath string) (string, error) {
if _, err := mdt.RunMvnCmd(goals); err != nil {
return "", err
}

mavenDepTreeOutput, err := os.ReadFile(mavenDepTreePath)
mavenDepTreeOutput, err := os.ReadFile(depTreeOutputPath)
if err != nil {
return "", errorutils.CheckError(err)
}
return string(mavenDepTreeOutput), nil
}

func (mdt *MavenDepTreeManager) runProjectsCmd() (string, error) {
goals := []string{"com.jfrog:maven-dep-tree:" + mavenDepTreeVersion + ":" + string(Projects), "-q"}
output, err := mdt.RunMvnCmd(goals)
if err != nil {
return "", err
}
return string(output), nil
}

func (mdt *MavenDepTreeManager) RunMvnCmd(goals []string) (cmdOutput []byte, err error) {
restoreMavenConfig, err := removeMavenConfig()
if err != nil {
Expand Down
Binary file modified xray/commands/audit/sca/java/resources/maven-dep-tree.jar
Binary file not shown.

0 comments on commit 24f553d

Please sign in to comment.