You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dolphinscheduler.apache.org by ga...@apache.org on 2020/07/15 09:37:18 UTC

[incubator-dolphinscheduler-maven-plugin] 14/22: all file add Apache License header

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

gaojun2048 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler-maven-plugin.git

commit c43ccd9bc2a83df20c3a5ce11e8b22899e16f346
Author: gaojun2048 <54...@qq.com>
AuthorDate: Tue Jun 16 12:16:07 2020 +0800

    all file add Apache License header
---
 .../maven/DolphinDescriptorGenerator.java          | 57 +++++++++++++---------
 .../maven/SpiDependencyChecker.java                | 17 +++++++
 .../maven/DolphinDescriptorGeneratorTest.java      | 17 +++++++
 .../maven/SpiDependencyCheckerTest.java            | 17 +++++++
 .../src/main/java/its/AbsTestPlugin.java           | 17 +++++++
 .../src/main/java/its/TestPluginImpl.java          | 17 +++++++
 .../src/main/java/its/ErrorScopeButSkipPlugin.java | 17 +++++++
 .../main/java/its/ErrorScopeDependencyPlugin.java  | 19 +++++++-
 .../src/main/java/its/ErrorScopeSpiPlugin.java     | 19 +++++++-
 .../src/main/java/its/SimplestPlugin.java          | 17 +++++++
 .../src/main/java/its/ITestPlugin.java             | 17 +++++++
 .../src/main/java/its/TestPluginImpl.java          | 17 +++++++
 .../src/main/java/its/SimplestPlugin.java          | 17 +++++++
 .../simplest/src/main/java/its/SimplestPlugin.java | 17 +++++++
 14 files changed, 257 insertions(+), 25 deletions(-)

diff --git a/src/main/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGenerator.java b/src/main/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGenerator.java
index 0733531..5eb26fd 100644
--- a/src/main/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGenerator.java
+++ b/src/main/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGenerator.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.dolphinscheduler.maven;
 
 import org.apache.maven.artifact.Artifact;
@@ -45,15 +62,19 @@ public class DolphinDescriptorGenerator extends AbstractMojo {
     public void execute()
             throws MojoExecutionException
     {
-        File servicesFile = new File(servicesDirectory, pluginClassName);
+        File spiServicesFile = new File(servicesDirectory, pluginClassName);
 
         // If users have already provided their own service file then we will not overwrite it
-        if (servicesFile.exists()) {
+        if (spiServicesFile.exists()) {
             return;
         }
 
-        if (!servicesFile.getParentFile().exists()) {
-            mkdirs(servicesFile.getParentFile());
+        if (!spiServicesFile.getParentFile().exists()) {
+            File file = spiServicesFile.getParentFile();
+            file.mkdirs();
+            if (!file.isDirectory()) {
+                throw new MojoExecutionException(String.format("%n%nFailed to create directory: %s", file));
+            }
         }
 
         List<Class<?>> pluginImplClasses;
@@ -78,8 +99,8 @@ public class DolphinDescriptorGenerator extends AbstractMojo {
 
         try {
             Class<?> pluginClass = pluginImplClasses.get(0);
-            Files.write(servicesFile.toPath(), pluginClass.getName().getBytes(UTF_8));
-            getLog().info(String.format("Wrote %s to %s", pluginClass.getName(), servicesFile));
+            Files.write(spiServicesFile.toPath(), pluginClass.getName().getBytes(UTF_8));
+            getLog().info(String.format("Wrote %s to %s", pluginClass.getName(), spiServicesFile));
         }
         catch (IOException e) {
             throw new MojoExecutionException("Failed to write services JAR file.", e);
@@ -89,17 +110,17 @@ public class DolphinDescriptorGenerator extends AbstractMojo {
     private URLClassLoader createCLFromCompileTimeDependencies()
             throws Exception
     {
-        List<URL> urls = new ArrayList<>();
-        urls.add(classesDirectory.toURI().toURL());
+        List<URL> classesUrls = new ArrayList<>();
+        classesUrls.add(classesDirectory.toURI().toURL());
         for (Artifact artifact : project.getArtifacts()) {
             if (artifact.getFile() != null) {
-                urls.add(artifact.getFile().toURI().toURL());
+                classesUrls.add(artifact.getFile().toURI().toURL());
             }
         }
-        return new URLClassLoader(urls.toArray(new URL[0]));
+        return new URLClassLoader(classesUrls.toArray(new URL[0]));
     }
 
-    private List<Class<?>> findPluginImplClasses(URLClassLoader searchRealm)
+    private List<Class<?>> findPluginImplClasses(URLClassLoader urlClassLoader)
             throws IOException, MojoExecutionException
     {
         List<Class<?>> implementations = new ArrayList<>();
@@ -107,8 +128,8 @@ public class DolphinDescriptorGenerator extends AbstractMojo {
         for (String classPath : classes) {
             String className = classPath.substring(0, classPath.length() - 6).replace(File.separatorChar, '.');
             try {
-                Class<?> pluginClass = searchRealm.loadClass(pluginClassName);
-                Class<?> clazz = searchRealm.loadClass(className);
+                Class<?> pluginClass = urlClassLoader.loadClass(pluginClassName);
+                Class<?> clazz = urlClassLoader.loadClass(className);
                 if (isImplementation(clazz, pluginClass)) {
                     implementations.add(clazz);
                 }
@@ -120,16 +141,6 @@ public class DolphinDescriptorGenerator extends AbstractMojo {
         return implementations;
     }
 
-    @SuppressWarnings("ResultOfMethodCallIgnored")
-    private static void mkdirs(File file)
-            throws MojoExecutionException
-    {
-        file.mkdirs();
-        if (!file.isDirectory()) {
-            throw new MojoExecutionException(String.format("%n%nFailed to create directory: %s", file));
-        }
-    }
-
     private static boolean isImplementation(Class<?> clazz, Class<?> pluginClass)
     {
         return pluginClass.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers()) && !Modifier.isInterface(clazz.getModifiers());
diff --git a/src/main/java/org/apache/dolphinscheduler/maven/SpiDependencyChecker.java b/src/main/java/org/apache/dolphinscheduler/maven/SpiDependencyChecker.java
index 6738cc9..62452ff 100644
--- a/src/main/java/org/apache/dolphinscheduler/maven/SpiDependencyChecker.java
+++ b/src/main/java/org/apache/dolphinscheduler/maven/SpiDependencyChecker.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.dolphinscheduler.maven;
 
 import org.apache.maven.artifact.Artifact;
diff --git a/src/test/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGeneratorTest.java b/src/test/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGeneratorTest.java
index 6a1c09a..10f9a62 100644
--- a/src/test/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGeneratorTest.java
+++ b/src/test/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGeneratorTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.dolphinscheduler.maven;
 
 import io.takari.maven.testing.TestResources;
diff --git a/src/test/java/org/apache/dolphinscheduler/maven/SpiDependencyCheckerTest.java b/src/test/java/org/apache/dolphinscheduler/maven/SpiDependencyCheckerTest.java
index fe8abd2..bc51dd5 100644
--- a/src/test/java/org/apache/dolphinscheduler/maven/SpiDependencyCheckerTest.java
+++ b/src/test/java/org/apache/dolphinscheduler/maven/SpiDependencyCheckerTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.dolphinscheduler.maven;
 
 import io.takari.maven.testing.TestResources;
diff --git a/src/test/projects/abstract-plugin-class/src/main/java/its/AbsTestPlugin.java b/src/test/projects/abstract-plugin-class/src/main/java/its/AbsTestPlugin.java
index bde697e..63d0018 100644
--- a/src/test/projects/abstract-plugin-class/src/main/java/its/AbsTestPlugin.java
+++ b/src/test/projects/abstract-plugin-class/src/main/java/its/AbsTestPlugin.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
 import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
diff --git a/src/test/projects/abstract-plugin-class/src/main/java/its/TestPluginImpl.java b/src/test/projects/abstract-plugin-class/src/main/java/its/TestPluginImpl.java
index 7b3306d..71766ab 100644
--- a/src/test/projects/abstract-plugin-class/src/main/java/its/TestPluginImpl.java
+++ b/src/test/projects/abstract-plugin-class/src/main/java/its/TestPluginImpl.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
 import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
diff --git a/src/test/projects/error-scope-but-skip/src/main/java/its/ErrorScopeButSkipPlugin.java b/src/test/projects/error-scope-but-skip/src/main/java/its/ErrorScopeButSkipPlugin.java
index 1a9fc98..9d70745 100644
--- a/src/test/projects/error-scope-but-skip/src/main/java/its/ErrorScopeButSkipPlugin.java
+++ b/src/test/projects/error-scope-but-skip/src/main/java/its/ErrorScopeButSkipPlugin.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
 import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
diff --git a/src/test/projects/error-scope-dependency/src/main/java/its/ErrorScopeDependencyPlugin.java b/src/test/projects/error-scope-dependency/src/main/java/its/ErrorScopeDependencyPlugin.java
index ad63c10..6ebaeff 100644
--- a/src/test/projects/error-scope-dependency/src/main/java/its/ErrorScopeDependencyPlugin.java
+++ b/src/test/projects/error-scope-dependency/src/main/java/its/ErrorScopeDependencyPlugin.java
@@ -1,6 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
-        import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
+import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
 
 public class ErrorScopeDependencyPlugin implements DolphinSchedulerPlugin {
 }
diff --git a/src/test/projects/error-scope-spi/src/main/java/its/ErrorScopeSpiPlugin.java b/src/test/projects/error-scope-spi/src/main/java/its/ErrorScopeSpiPlugin.java
index 8300a91..36d03ef 100644
--- a/src/test/projects/error-scope-spi/src/main/java/its/ErrorScopeSpiPlugin.java
+++ b/src/test/projects/error-scope-spi/src/main/java/its/ErrorScopeSpiPlugin.java
@@ -1,6 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
-        import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
+import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
 
 public class ErrorScopeSpiPlugin implements DolphinSchedulerPlugin {
 }
diff --git a/src/test/projects/excluded-dependency/src/main/java/its/SimplestPlugin.java b/src/test/projects/excluded-dependency/src/main/java/its/SimplestPlugin.java
index 5965dd6..53fc1d3 100644
--- a/src/test/projects/excluded-dependency/src/main/java/its/SimplestPlugin.java
+++ b/src/test/projects/excluded-dependency/src/main/java/its/SimplestPlugin.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
 import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
diff --git a/src/test/projects/interface-plugin-class/src/main/java/its/ITestPlugin.java b/src/test/projects/interface-plugin-class/src/main/java/its/ITestPlugin.java
index 351c0b1..211b0d0 100644
--- a/src/test/projects/interface-plugin-class/src/main/java/its/ITestPlugin.java
+++ b/src/test/projects/interface-plugin-class/src/main/java/its/ITestPlugin.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
 import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
diff --git a/src/test/projects/interface-plugin-class/src/main/java/its/TestPluginImpl.java b/src/test/projects/interface-plugin-class/src/main/java/its/TestPluginImpl.java
index 8109d48..5af1917 100644
--- a/src/test/projects/interface-plugin-class/src/main/java/its/TestPluginImpl.java
+++ b/src/test/projects/interface-plugin-class/src/main/java/its/TestPluginImpl.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
 import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
diff --git a/src/test/projects/more-excluded-dependency/src/main/java/its/SimplestPlugin.java b/src/test/projects/more-excluded-dependency/src/main/java/its/SimplestPlugin.java
index 5965dd6..53fc1d3 100644
--- a/src/test/projects/more-excluded-dependency/src/main/java/its/SimplestPlugin.java
+++ b/src/test/projects/more-excluded-dependency/src/main/java/its/SimplestPlugin.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
 import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
diff --git a/src/test/projects/simplest/src/main/java/its/SimplestPlugin.java b/src/test/projects/simplest/src/main/java/its/SimplestPlugin.java
index 5965dd6..53fc1d3 100644
--- a/src/test/projects/simplest/src/main/java/its/SimplestPlugin.java
+++ b/src/test/projects/simplest/src/main/java/its/SimplestPlugin.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package its;
 
 import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;