Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump maven-dep-tree to 1.1.0 #1097

Merged
merged 6 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
30 changes: 12 additions & 18 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,29 @@ func GetMavenPluginInstallationGoals(pluginPath string) []string {
}

func (mdt *MavenDepTreeManager) execMavenDepTree(depTreeExecDir string) (string, error) {
if mdt.cmdName == Tree {
return mdt.runTreeCmd(depTreeExecDir)
depTreeOutputPath := filepath.Join(depTreeExecDir, mavenDepTreeOutputFile)
var goals []string
switch mdt.cmdName {
case Tree:
goals = []string{"com.jfrog:maven-dep-tree:" + mavenDepTreeVersion + ":" + string(Tree), "-DdepsTreeOutputFile=" + depTreeOutputPath, "-B"}
case Projects:
goals = []string{"com.jfrog:maven-dep-tree:" + mavenDepTreeVersion + ":" + string(Projects), "-q", "-DdepsTreeOutputFile=" + depTreeOutputPath}
omerzi marked this conversation as resolved.
Show resolved Hide resolved
}
return mdt.runProjectsCmd()

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.
Loading