From a618c7431ac89ebdb8a4168b8213867e00f5fbd8 Mon Sep 17 00:00:00 2001 From: Tadayoshi Sato Date: Thu, 26 Aug 2021 12:54:46 +0900 Subject: [PATCH] fix(jolokia): exclude com.sun:tools for broken jolokia-jvm pom --- pkg/util/camel/camel_dependencies.go | 8 ++++++++ pkg/util/maven/maven_project.go | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/util/camel/camel_dependencies.go b/pkg/util/camel/camel_dependencies.go index 9f2c439e8f..38fadb8cc0 100644 --- a/pkg/util/camel/camel_dependencies.go +++ b/pkg/util/camel/camel_dependencies.go @@ -89,6 +89,14 @@ func ManageIntegrationDependencies( gav := strings.TrimPrefix(d, "mvn:") project.AddEncodedDependencyGAV(gav) + // hack for tools.jar dependency issue in jolokia-jvm + if strings.Contains(gav, "org.jolokia:jolokia-jvm") { + me := maven.Exclusion{ + GroupID: "com.sun", + ArtifactID: "tools", + } + project.AddEncodedDependencyExclusion(gav, me) + } default: if dep := jitpack.ToDependency(d); dep != nil { project.AddDependency(*dep) diff --git a/pkg/util/maven/maven_project.go b/pkg/util/maven/maven_project.go index e9ed19ddc5..ac1b86e9a4 100644 --- a/pkg/util/maven/maven_project.go +++ b/pkg/util/maven/maven_project.go @@ -109,12 +109,12 @@ func (p *Project) AddDependencies(deps ...Dependency) { } } -// AddDependencyGAV a dependency to maven's dependencies +// AddDependencyGAV adds a dependency to maven's dependencies func (p *Project) AddDependencyGAV(groupID string, artifactID string, version string) { p.AddDependency(NewDependency(groupID, artifactID, version)) } -// AddEncodedDependencyGAV a dependency to maven's dependencies +// AddEncodedDependencyGAV adds a dependency in GAV format to maven's dependencies func (p *Project) AddEncodedDependencyGAV(gav string) { if d, err := ParseGAV(gav); err == nil { // TODO: error handling @@ -145,6 +145,13 @@ func (p *Project) AddDependencyExclusions(dep Dependency, exclusions ...Exclusio } } +func (p *Project) AddEncodedDependencyExclusion(gav string, exclusion Exclusion) { + if d, err := ParseGAV(gav); err == nil { + // TODO: error handling + p.AddDependencyExclusion(d, exclusion) + } +} + type propertiesEntry struct { XMLName xml.Name Value string `xml:",chardata"`