Skip to content

Commit

Permalink
Update to camel 3.0.0-M4 apache#94
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Jul 15, 2019
1 parent 229bea2 commit 2a88332
Show file tree
Hide file tree
Showing 23 changed files with 210 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.apache.camel.k.tooling.maven;

import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand All @@ -29,6 +28,7 @@
import java.util.ServiceLoader;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.regex.Pattern;
import java.util.stream.StreamSupport;

import com.fasterxml.jackson.annotation.JsonInclude;
Expand All @@ -54,7 +54,6 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.io.IOUtil;

@Mojo(
name = "generate-catalog",
Expand Down Expand Up @@ -167,6 +166,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {
private void processComponents(org.apache.camel.catalog.CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
for (String name : catalog.findComponentNames()) {
String json = catalog.componentJSonSchema(name);

if ("rest-swagger".equalsIgnoreCase(name)) {
// TODO: workaround for https://issues.apache.org/jira/browse/CAMEL-13588
json = json.replaceAll(Pattern.quote("\\h"), "h");
}

CatalogComponentDefinition definition = CatalogSupport.unmarshallComponent(json);

artifacts.compute(definition.getArtifactId(), (key, artifact) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public void process(MavenProject project, CamelCatalog catalog, Map<String, Came
artifact.setGroupId("org.apache.camel.k");
artifact.setArtifactId("camel-k-runtime-jvm");
artifact.setVersion(project.getVersion());
artifact.addDependency("org.apache.camel", "camel-core");
artifact.addDependency("org.apache.camel", "camel-core-engine");
artifact.addDependency("org.apache.camel", "camel-main");
artifact.addDependency("org.apache.camel", "camel-properties");

artifacts.put(artifact.getArtifactId(), artifact);
}
Expand Down Expand Up @@ -196,6 +198,26 @@ public void process(MavenProject project, CamelCatalog catalog, Map<String, Came
artifacts.put(artifact.getArtifactId(), artifact);
}

// ************************
//
// camel-http4
//
// ************************

{
CamelArtifact artifact = new CamelArtifact();
artifact.setGroupId("org.apache.camel.k");
artifact.setArtifactId("camel-k-runtime-knative");
artifact.addDependency("org.apache.camel.k", "camel-k-runtime-yaml");
artifact.addDependency("org.apache.camel.k", "camel-knative");
artifact.addDependency("org.apache.camel.k", "camel-knative-http");
artifact.addDependency("org.apache.camel", "camel-netty4-http");

artifacts.put(artifact.getArtifactId(), artifact);


}

// ************************
//
//
Expand All @@ -208,5 +230,16 @@ public void process(MavenProject project, CamelCatalog catalog, Map<String, Came
for (String scheme: KNOWN_PASSIVE_URIS) {
artifacts.values().forEach(artifact -> artifact.getScheme(scheme).ifPresent(s -> s.setPassive(true)));
}

// ************************
//
//
//
// ************************

artifacts.computeIfPresent("camel-http4", (key, artifact) -> {
artifact.addDependency("org.apache.camel", "camel-file");
return artifact;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ public void testArtifactsEnrichment() {
CatalogProcessor processor = new CatalogProcessor3x();
CamelCatalog catalog = versionCamelCatalog("3.0.0");
Map<String, CamelArtifact> artifactMap = new HashMap<>();
artifactMap.put("camel-http4", new CamelArtifact());

assertThat(processor.accepts(catalog)).isTrue();
processor.process(new MavenProject(), catalog, artifactMap);


assertThat(artifactMap.get("camel-k-runtime-jvm")).satisfies(a -> {
assertThat(a.getDependencies()).anyMatch(
d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-core")
d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-core-engine")
);
assertThat(a.getDependencies()).anyMatch(
d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-properties")
);
});
assertThat(artifactMap.get("camel-k-runtime-groovy")).satisfies(a -> {
Expand Down Expand Up @@ -126,5 +130,11 @@ public void testArtifactsEnrichment() {
d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-netty4-http")
);
});

assertThat(artifactMap.get("camel-http4")).satisfies(a -> {
assertThat(a.getDependencies()).anyMatch(
d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-file")
);
});
}
}
12 changes: 1 addition & 11 deletions camel-k-runtime-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,7 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-base</artifactId>
<artifactId>camel-core-engine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.camel.CamelContext;
import org.apache.camel.component.properties.PropertiesComponent;
Expand All @@ -40,38 +41,20 @@ public final class PropertiesSupport {
private PropertiesSupport() {
}

public static int bindProperties(CamelContext context, Object target, String prefix) {
public static boolean bindProperties(CamelContext context, Object target, String prefix) {
final PropertiesComponent component = context.getComponent("properties", PropertiesComponent.class);
final Properties properties = component.loadProperties();

if (properties == null) {
return 0;
return false;
}

return bindProperties(context, properties, target, prefix);
}

public static int bindProperties(CamelContext context, Properties properties, Object target, String prefix) {
final AtomicInteger count = new AtomicInteger();

properties.entrySet().stream()
.filter(entry -> entry.getKey() instanceof String)
.filter(entry -> entry.getValue() != null)
.filter(entry -> ((String)entry.getKey()).startsWith(prefix))
.forEach(entry -> {
final String key = ((String)entry.getKey()).substring(prefix.length());
final Object val = entry.getValue();

try {
if (PropertyBindingSupport.bindProperty(context, target, key, val)) {
count.incrementAndGet();
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
});
Map<String, Object> props = new HashMap<>();
for (String key : properties.stringPropertyNames()) {
props.put(key, properties.get(key));
}

return count.get();
return PropertyBindingSupport.bindProperties(context, target, props, prefix);
}

public static Properties loadProperties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-core-engine</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-core-engine</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-core-engine</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
Expand Down
29 changes: 25 additions & 4 deletions camel-k-runtime-groovy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-api</artifactId>
<artifactId>camel-core-engine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-main</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-runtime-core</artifactId>
<groupId>org.apache.camel</groupId>
<artifactId>camel-log</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -73,6 +74,26 @@
<!-- -->
<!-- ****************************** -->

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-timer</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-seda</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-rest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-direct</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-properties</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion camel-k-runtime-health/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-core-engine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
32 changes: 31 additions & 1 deletion camel-k-runtime-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-core-engine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-main</artifactId>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -78,6 +83,31 @@
<artifactId>camel-undertow</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-timer</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-seda</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-log</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-rest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-direct</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-properties</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion camel-k-runtime-knative/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-core-engine</artifactId>
<scope>provided</scope>
</dependency>

Expand Down
32 changes: 31 additions & 1 deletion camel-k-runtime-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-core-engine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-main</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-log</artifactId>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -66,6 +76,26 @@
<!-- -->
<!-- ****************************** -->

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-timer</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-seda</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-rest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-direct</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-properties</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion camel-k-runtime-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<artifactId>camel-core-engine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Loading

0 comments on commit 2a88332

Please sign in to comment.