You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2018/11/15 15:30:43 UTC
[camel-k] 01/03: Auto-detect Jackson
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 7b791bd2a9e8e77594d68bb5da2d1b02b30399fd
Author: nferraro <ni...@gmail.com>
AuthorDate: Sun Nov 11 23:54:59 2018 +0100
Auto-detect Jackson
---
pkg/metadata/dependencies.go | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/pkg/metadata/dependencies.go b/pkg/metadata/dependencies.go
index 5dce778..020b3b6 100644
--- a/pkg/metadata/dependencies.go
+++ b/pkg/metadata/dependencies.go
@@ -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
+}