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

Update to camel 3.0.0-M4 #95

Merged
merged 1 commit into from Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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;
});
}
}
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
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
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
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
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
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
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
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
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
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
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
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