This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 043836ac1c9dc4284faa1a8d59c665d829a2d663
Author: lburgazzoli <lburgazz...@gmail.com>
AuthorDate: Sat Oct 20 15:50:45 2018 +0200

    chore(build): remove deprecated methos
---
 runtime/dependency-lister/pom.xml                  |  4 +-
 .../maven/dependency/DependencyListerMojo.java     | 54 +++++++++++-----------
 .../java/org/apache/camel/k/jvm/RoutesLoaders.java |  2 +-
 runtime/pom.xml                                    | 10 ++++
 4 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/runtime/dependency-lister/pom.xml 
b/runtime/dependency-lister/pom.xml
index d4ae16b..1c4bfa7 100644
--- a/runtime/dependency-lister/pom.xml
+++ b/runtime/dependency-lister/pom.xml
@@ -35,7 +35,7 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
-      <version>3.5.2</version>
+      <version>3.5.4</version>
       <exclusions>
         <exclusion>
           <groupId>*</groupId>
@@ -72,7 +72,7 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>3.5.2</version>
+      <version>3.5.4</version>
       <exclusions>
         <exclusion>
           <groupId>*</groupId>
diff --git 
a/runtime/dependency-lister/src/main/java/org/apache/camel/k/tooling/maven/dependency/DependencyListerMojo.java
 
b/runtime/dependency-lister/src/main/java/org/apache/camel/k/tooling/maven/dependency/DependencyListerMojo.java
index 780c9e8..1afe9df 100644
--- 
a/runtime/dependency-lister/src/main/java/org/apache/camel/k/tooling/maven/dependency/DependencyListerMojo.java
+++ 
b/runtime/dependency-lister/src/main/java/org/apache/camel/k/tooling/maven/dependency/DependencyListerMojo.java
@@ -16,23 +16,23 @@
  */
 package org.apache.camel.k.tooling.maven.dependency;
 
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Writer;
-import java.util.ArrayList;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
@@ -45,16 +45,10 @@ import org.yaml.snakeyaml.Yaml;
 @Mojo(
     name = "generate-dependency-list",
     defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
-    requiresProject = true,
     threadSafe = true,
     requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
     requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
-@SuppressWarnings({ "PMD.GodClass", "PMD.TooManyFields", "PMD.TooManyMethods" 
})
 public class DependencyListerMojo extends AbstractMojo {
-
-    @Component
-    private ArtifactFactory artifactFactory;
-
     @Parameter(readonly = true, defaultValue = "${project}")
     private MavenProject project;
 
@@ -63,26 +57,21 @@ public class DependencyListerMojo extends AbstractMojo {
 
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
-        List<Map<String, String>> deps = new ArrayList<>();
-
-        
project.getArtifacts().stream().filter(this::isCompileOrRuntime).forEach(artifact
 -> {
-                Map<String, String> dep = new HashMap<>();
-                dep.put("id", artifact.getId());
+        final Path output = Paths.get(this.destination);
 
-                if (artifact.getFile() != null) {
-                    dep.put("location", artifact.getFile().getAbsolutePath());
-                }
-
-                deps.add(dep);
+        try {
+            if (Files.notExists(output.getParent())) {
+                Files.createDirectories(output.getParent());
             }
-        );
-
-        File dest = new File(destination);
-        if (!dest.getParentFile().exists()) {
-            dest.getParentFile().mkdirs();
+        } catch (IOException e) {
+            throw new MojoExecutionException("Exception while generating 
dependencies list", e);
         }
 
-        try (Writer writer = new FileWriter(dest)) {
+        try (Writer writer = Files.newBufferedWriter(output, 
StandardCharsets.UTF_8)) {
+            List<Map<String, String>> deps = project.getArtifacts().stream()
+                .filter(this::isCompileOrRuntime)
+                .map(this::artifactToMap)
+                .collect(Collectors.toList());
 
             DumperOptions options = new DumperOptions();
             options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
@@ -98,4 +87,15 @@ public class DependencyListerMojo extends AbstractMojo {
         return StringUtils.equals(artifact.getScope(), 
DefaultArtifact.SCOPE_COMPILE)
             || StringUtils.equals(artifact.getScope(), 
DefaultArtifact.SCOPE_RUNTIME);
     }
+
+    private Map<String, String> artifactToMap(Artifact artifact) {
+        Map<String, String> dep = new HashMap<>();
+        dep.put("id", artifact.getId());
+
+        if (artifact.getFile() != null) {
+            dep.put("location", artifact.getFile().getAbsolutePath());
+        }
+
+        return dep;
+    }
 }
diff --git 
a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoaders.java 
b/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoaders.java
index 1d69c8e..0ffafbc 100644
--- a/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoaders.java
+++ b/runtime/jvm/src/main/java/org/apache/camel/k/jvm/RoutesLoaders.java
@@ -95,7 +95,7 @@ public final class RoutesLoaders {
                         }
 
                         // Wrap routes builder
-                        addRoutes(
+                        includeRoutes(
                             Reflect.compile(name, IOUtils.toString(is, 
StandardCharsets.UTF_8)).create().get()
                         );
                     }
diff --git a/runtime/pom.xml b/runtime/pom.xml
index 10bc293..15506c3 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -73,6 +73,16 @@
                     <artifactId>fabric8-maven-plugin</artifactId>
                     <version>${fabric8-maven-plugin.version}</version>
                 </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>3.8.0</version>
+                    <configuration>
+                        <compilerArgs>
+                            <arg>-Xlint:deprecation</arg>
+                        </compilerArgs>
+                    </configuration>
+                </plugin>
             </plugins>
         </pluginManagement>
     </build>

Reply via email to