Auto-detect Jackson
@@ -18,6 +18,7 @@ limitations under the License.
package metadata
import (
+ "regexp"
"sort"
"strings"
@@ -25,6 +26,12 @@ import (
"github.com/apache/camel-k/pkg/util/camel"
)
+var (
+ additionalDependencies = map[string]string {
+ ".*JsonLibrary\\.Jackson.*": "camel:jackson",
+ }
+)
+
// discoverDependencies returns a list of dependencies required by the given source code
func discoverDependencies(source v1alpha1.SourceSpec, fromURIs []string, toURIs []string) []string {
candidateMap := make(map[string]bool)
@@ -37,6 +44,10 @@ func discoverDependencies(source v1alpha1.SourceSpec, fromURIs []string, toURIs
candidateMap[candidateComp] = true
}
}
+ additional := findAdditionalDependencies(source)
+ for _, dep := range additional {
+ candidateMap[dep] = true
+ }
// Remove duplicates and sort
candidateComponents := make([]string, 0, len(candidateMap))
for cmp := range candidateMap {
@@ -61,3 +72,14 @@ func decodeComponent(uri string) string {
}
return ""
}
+
+func findAdditionalDependencies(source v1alpha1.SourceSpec) []string {
+ additional := make([]string, 0)
+ for pattern, dep := range additionalDependencies {
+ pat := regexp.MustCompile(pattern)
+ if pat.MatchString(source.Content) {
+ additional = append(additional, dep)
+ }
+ }
+ return additional
+}
