From 2728f9650531f6ee472c0832e0d9a2202b6c90b3 Mon Sep 17 00:00:00 2001 From: Balaji Varadarajan Date: Mon, 17 Sep 2018 00:25:24 -0700 Subject: [PATCH] Add dummy classes to dump all classes loaded as part of packaging modules to ensure javadoc and sources jars are getting created --- .../hoodie/common/util/ReflectionUtils.java | 17 +++++++++ packaging/hoodie-hadoop-mr-bundle/pom.xml | 1 - .../com/uber/hoodie/hadoop/bundle/Main.java | 36 +++++++++++++++++++ .../com/uber/hoodie/hive/bundle/Main.java | 36 +++++++++++++++++++ .../com/uber/hoodie/spark/bundle/Main.java | 36 +++++++++++++++++++ 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 packaging/hoodie-hadoop-mr-bundle/src/main/java/com/uber/hoodie/hadoop/bundle/Main.java create mode 100644 packaging/hoodie-hive-bundle/src/main/java/com/uber/hoodie/hive/bundle/Main.java create mode 100644 packaging/hoodie-spark-bundle/src/main/java/com/uber/hoodie/spark/bundle/Main.java diff --git a/hoodie-common/src/main/java/com/uber/hoodie/common/util/ReflectionUtils.java b/hoodie-common/src/main/java/com/uber/hoodie/common/util/ReflectionUtils.java index 7416067e0..54348d5f5 100644 --- a/hoodie-common/src/main/java/com/uber/hoodie/common/util/ReflectionUtils.java +++ b/hoodie-common/src/main/java/com/uber/hoodie/common/util/ReflectionUtils.java @@ -16,12 +16,16 @@ package com.uber.hoodie.common.util; +import com.google.common.reflect.ClassPath; +import com.google.common.reflect.ClassPath.ClassInfo; import com.uber.hoodie.common.model.HoodieRecordPayload; import com.uber.hoodie.exception.HoodieException; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.stream.Stream; public class ReflectionUtils { @@ -82,4 +86,17 @@ public class ReflectionUtils { .map(arg -> arg.getClass()).toArray(Class[]::new); return loadClass(clazz, constructorArgTypes, constructorArgs); } + + /** + * Return stream of top level class names in the same class path as passed-in class + * @param clazz + */ + public static Stream getTopLevelClassesInClasspath(Class clazz) { + try { + ClassPath classPath = ClassPath.from(clazz.getClassLoader()); + return classPath.getTopLevelClasses().stream().map(ClassInfo::getName); + } catch (IOException e) { + throw new RuntimeException("Got exception while dumping top level classes", e); + } + } } diff --git a/packaging/hoodie-hadoop-mr-bundle/pom.xml b/packaging/hoodie-hadoop-mr-bundle/pom.xml index 9e20c1faf..121f72fbc 100644 --- a/packaging/hoodie-hadoop-mr-bundle/pom.xml +++ b/packaging/hoodie-hadoop-mr-bundle/pom.xml @@ -172,7 +172,6 @@ ${project.artifactId}-${project.version}${hiveJarSuffix} - ${hiveJarSuffix} diff --git a/packaging/hoodie-hadoop-mr-bundle/src/main/java/com/uber/hoodie/hadoop/bundle/Main.java b/packaging/hoodie-hadoop-mr-bundle/src/main/java/com/uber/hoodie/hadoop/bundle/Main.java new file mode 100644 index 000000000..749de725e --- /dev/null +++ b/packaging/hoodie-hadoop-mr-bundle/src/main/java/com/uber/hoodie/hadoop/bundle/Main.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Uber Technologies, Inc. (hoodie-dev-group@uber.com) + * + * Licensed 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 com.uber.hoodie.hadoop.bundle; + +import com.uber.hoodie.common.util.ReflectionUtils; + +/** + * A simple main class to dump all classes loaded in current classpath + * + * This is a workaround for generating sources and javadoc jars for packaging modules. The maven plugins for generating + * javadoc and sources plugins do not generate corresponding jars if there are no source files. + * + * This class does not have anything to do with Hudi but is there to keep mvn javadocs/source plugin happy. + */ +public class Main { + + public static void main(String[] args) { + ReflectionUtils.getTopLevelClassesInClasspath(Main.class).forEach(System.out::println); + } +} diff --git a/packaging/hoodie-hive-bundle/src/main/java/com/uber/hoodie/hive/bundle/Main.java b/packaging/hoodie-hive-bundle/src/main/java/com/uber/hoodie/hive/bundle/Main.java new file mode 100644 index 000000000..dad7e3af7 --- /dev/null +++ b/packaging/hoodie-hive-bundle/src/main/java/com/uber/hoodie/hive/bundle/Main.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Uber Technologies, Inc. (hoodie-dev-group@uber.com) + * + * Licensed 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 com.uber.hoodie.hive.bundle; + +import com.uber.hoodie.common.util.ReflectionUtils; + +/** + * A simple main class to dump all classes loaded in current classpath. + * + * This is a workaround for generating sources and javadoc jars for packaging modules. The maven plugins for generating + * javadoc and sources plugins do not generate corresponding jars if there are no source files. + * + * This class does not have anything to do with Hudi but is there to keep mvn javadocs/source plugin happy. + */ +public class Main { + + public static void main(String[] args) { + ReflectionUtils.getTopLevelClassesInClasspath(Main.class).forEach(System.out::println); + } +} diff --git a/packaging/hoodie-spark-bundle/src/main/java/com/uber/hoodie/spark/bundle/Main.java b/packaging/hoodie-spark-bundle/src/main/java/com/uber/hoodie/spark/bundle/Main.java new file mode 100644 index 000000000..9daead7d7 --- /dev/null +++ b/packaging/hoodie-spark-bundle/src/main/java/com/uber/hoodie/spark/bundle/Main.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Uber Technologies, Inc. (hoodie-dev-group@uber.com) + * + * Licensed 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 com.uber.hoodie.spark.bundle; + +import com.uber.hoodie.common.util.ReflectionUtils; + +/** + * A simple main class to dump all classes loaded in current classpath + * + * This is a workaround for generating sources and javadoc jars for packaging modules. The maven plugins for generating + * javadoc and sources plugins do not generate corresponding jars if there are no source files. + * + * This class does not have anything to do with Hudi but is there to keep mvn javadocs/source plugin happy. + */ +public class Main { + + public static void main(String[] args) { + ReflectionUtils.getTopLevelClassesInClasspath(Main.class).forEach(System.out::println); + } +}