http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java b/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java index 2612ec2..3972a54 100644 --- a/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java +++ b/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java @@ -1,6 +1,6 @@ package org.apache.streams.plugins.hbase; -import org.apache.streams.schema.GenerationConfig; +import org.apache.streams.util.schema.GenerationConfig; import org.jsonschema2pojo.DefaultGenerationConfig; import org.jsonschema2pojo.util.URLUtil;
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGenerator.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGenerator.java b/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGenerator.java index 649bdd9..71a8705 100644 --- a/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGenerator.java +++ b/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGenerator.java @@ -3,21 +3,18 @@ package org.apache.streams.plugins.hbase; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Joiner; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; import com.google.common.collect.Lists; -import org.apache.streams.schema.FieldType; -import org.apache.streams.schema.FieldUtil; -import org.apache.streams.schema.GenerationConfig; -import org.apache.streams.schema.Schema; -import org.apache.streams.schema.SchemaStore; +import org.apache.streams.util.schema.FieldType; +import org.apache.streams.util.schema.FieldUtil; +import org.apache.streams.util.schema.GenerationConfig; +import org.apache.streams.util.schema.Schema; +import org.apache.streams.util.schema.SchemaStore; +import org.apache.streams.util.schema.SchemaStoreImpl; import org.jsonschema2pojo.util.URLUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.net.URI; import java.net.URL; import java.util.Iterator; import java.util.LinkedList; @@ -25,11 +22,11 @@ import java.util.List; import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; -import static org.apache.streams.schema.FileUtil.dropExtension; -import static org.apache.streams.schema.FileUtil.dropSourcePathPrefix; -import static org.apache.streams.schema.FileUtil.resolveRecursive; -import static org.apache.streams.schema.FileUtil.swapExtension; -import static org.apache.streams.schema.FileUtil.writeFile; +import static org.apache.streams.util.schema.FileUtil.dropExtension; +import static org.apache.streams.util.schema.FileUtil.dropSourcePathPrefix; +import static org.apache.streams.util.schema.FileUtil.resolveRecursive; +import static org.apache.streams.util.schema.FileUtil.swapExtension; +import static org.apache.streams.util.schema.FileUtil.writeFile; /** * Created by sblackmon on 5/3/16. @@ -42,7 +39,7 @@ public class StreamsHbaseResourceGenerator implements Runnable { private StreamsHbaseGenerationConfig config; - private SchemaStore schemaStore = new SchemaStore(); + private SchemaStore schemaStore = new SchemaStoreImpl(); private int currentDepth = 0; @@ -60,17 +57,9 @@ public class StreamsHbaseResourceGenerator implements Runnable { config.setSourceDirectory(sourceDirectory); config.setTargetDirectory(targetDirectory); - StreamsHbaseResourceGenerator StreamsHbaseResourceGenerator = new StreamsHbaseResourceGenerator(config); - Thread thread = new Thread(StreamsHbaseResourceGenerator); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - } - return; + StreamsHbaseResourceGenerator streamsHbaseResourceGenerator = new StreamsHbaseResourceGenerator(config); + streamsHbaseResourceGenerator.run(); + } public StreamsHbaseResourceGenerator(StreamsHbaseGenerationConfig config) { http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGeneratorMojo.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGeneratorMojo.java b/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGeneratorMojo.java index 0db68f0..6bad40b 100644 --- a/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGeneratorMojo.java +++ b/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseResourceGeneratorMojo.java @@ -15,10 +15,10 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.util.List; -@Mojo( name = "hbase", +@Mojo( name = "generate-resources", defaultPhase = LifecyclePhase.GENERATE_RESOURCES ) -@Execute( goal = "hbase", +@Execute( goal = "generate-resources", phase = LifecyclePhase.GENERATE_RESOURCES ) public class StreamsHbaseResourceGeneratorMojo extends AbstractMojo { @@ -64,30 +64,8 @@ public class StreamsHbaseResourceGeneratorMojo extends AbstractMojo { config.setTargetDirectory(targetDirectory); StreamsHbaseResourceGenerator streamsHbaseResourceGenerator = new StreamsHbaseResourceGenerator(config); + streamsHbaseResourceGenerator.run(); - Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() { - public void uncaughtException(Thread th, Throwable ex) { - LOGGER.error("Exception", ex); - mojoFailureException = new MojoFailureException("Exception", ex); - } - }; - Thread.setDefaultUncaughtExceptionHandler(h); - Thread thread = new Thread(streamsHbaseResourceGenerator); - thread.setUncaughtExceptionHandler(h); - try { - thread.start(); - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - mojoFailureException = new MojoFailureException("Exception", e); - } - - if( mojoFailureException != null ) - throw mojoFailureException; - - return; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hbase/src/site/markdown/index.md ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/site/markdown/index.md b/streams-plugins/streams-plugin-hbase/src/site/markdown/index.md index 858cb85..0a0c308 100644 --- a/streams-plugins/streams-plugin-hbase/src/site/markdown/index.md +++ b/streams-plugins/streams-plugin-hbase/src/site/markdown/index.md @@ -3,17 +3,35 @@ org.apache.streams.plugins:streams-plugin-hbase streams-plugin-hbase generates resources from json schemas to assist with indexing of json data using Apache HBase. -#### Usage +### Usage + +Output will be placed in target/generated-resources/hbase by default + +[streams-plugin-hbase/pom.xml](streams-plugin-hbase/pom.xml "streams-plugin-hbase/pom.xml") + +##### Maven Run within a module containing a src/main/jsonschema directory mvn org.apache.streams.plugins:streams-plugin-hbase:0.3-incubating-SNAPSHOT:hbase -Output will be placed in target/generated-resources/hive by default +##### SDK -#### Example +Embed within your own java code -[streams-plugin-hbase/pom.xml](streams-plugin-hbase/pom.xml "streams-plugin-hbase/pom.xml") + StreamsHbaseGenerationConfig config = new StreamsHbaseGenerationConfig(); + config.setSourceDirectory("src/main/jsonschema"); + config.setTargetDirectory("target/generated-resources"); + StreamsHbaseResourceGenerator generator = new StreamsHbaseResourceGenerator(config); + generator.run(); + +##### CLI + +Run from CLI without Maven + + java -jar streams-plugin-hbase-jar-with-dependencies.jar StreamsHbaseResourceGenerator src/main/jsonschema target/generated-resources + +#### Example #### Documentation http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java index 290d601..24eba24 100644 --- a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java +++ b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java @@ -21,7 +21,7 @@ public class StreamsHbaseResourceGeneratorCLITest { @Test public void testStreamsHiveResourceGeneratorCLI() throws Exception { - String sourceDirectory = "target/test-classes/streams-schemas"; + String sourceDirectory = "target/test-classes/streams-schema-activitystreams"; String targetDirectory = "target/generated-resources/hbase-cli"; List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java index 6293021..fc8c77a 100644 --- a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java +++ b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java @@ -51,7 +51,7 @@ public class StreamsHbaseResourceGeneratorMojoTest extends TestCase { verifier.resetStreams(); - File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/test-mojo"); + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/hbase-mojo"); assert( testOutput != null ); assert( testOutput.exists() == true ); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java index 02b0214..91a1a05 100644 --- a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java +++ b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java @@ -8,7 +8,6 @@ import org.apache.commons.io.FileUtils; import org.apache.streams.plugins.hbase.StreamsHbaseGenerationConfig; import org.apache.streams.plugins.hbase.StreamsHbaseResourceGenerator; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +17,7 @@ import java.io.File; import java.util.Collection; import java.util.Iterator; -import static org.apache.streams.schema.FileUtil.dropSourcePathPrefix; +import static org.apache.streams.util.schema.FileUtil.dropSourcePathPrefix; /** * Test that Activity beans are compatible with the example activities in the spec. @@ -46,11 +45,11 @@ public class StreamsHbaseResourceGeneratorTest { StreamsHbaseGenerationConfig config = new StreamsHbaseGenerationConfig(); - String sourceDirectory = "target/test-classes/streams-schemas"; + String sourceDirectory = "target/test-classes/streams-schema-activitystreams"; config.setSourceDirectory(sourceDirectory); - config.setTargetDirectory("target/generated-resources/test"); + config.setTargetDirectory("target/generated-resources/hbase"); config.setExclusions(Sets.newHashSet("attachments")); @@ -58,19 +57,10 @@ public class StreamsHbaseResourceGeneratorTest { config.setMaxDepth(2); StreamsHbaseResourceGenerator streamsHbaseResourceGenerator = new StreamsHbaseResourceGenerator(config); - Thread thread = new Thread(streamsHbaseResourceGenerator); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - } + streamsHbaseResourceGenerator.run(); File testOutput = config.getTargetDirectory(); - assert( testOutput != null ); assert( testOutput.exists() == true ); assert( testOutput.isDirectory() == true ); @@ -108,18 +98,5 @@ public class StreamsHbaseResourceGeneratorTest { Assert.fail(); } - -// assert( new File(testOutput + "/traits").exists() == true ); -// assert( new File(testOutput + "/traits").isDirectory() == true ); -// assert( new File(testOutput + "/traits").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/traits").listFiles(scalaFilter).length == 4 ); -// assert( new File(testOutput + "/objectTypes").exists() == true ); -// assert( new File(testOutput + "/objectTypes").isDirectory() == true ); -// assert( new File(testOutput + "/objectTypes").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/objectTypes").listFiles(scalaFilter).length == 43 ); -// assert( new File(testOutput + "/verbs").exists() == true ); -// assert( new File(testOutput + "/verbs").isDirectory() == true ); -// assert( new File(testOutput + "/verbs").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/verbs").listFiles(scalaFilter).length == 89 ); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hbase/src/test/resources/streams-plugin-hbase/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/test/resources/streams-plugin-hbase/pom.xml b/streams-plugins/streams-plugin-hbase/src/test/resources/streams-plugin-hbase/pom.xml index 9aa7d8d..a3fbeeb 100644 --- a/streams-plugins/streams-plugin-hbase/src/test/resources/streams-plugin-hbase/pom.xml +++ b/streams-plugins/streams-plugin-hbase/src/test/resources/streams-plugin-hbase/pom.xml @@ -18,9 +18,10 @@ </dependency> <dependency> <groupId>org.apache.streams</groupId> - <artifactId>streams-schemas</artifactId> + <artifactId>streams-schema-activitystreams</artifactId> <version>${project.version}</version> <scope>test</scope> + <type>test-jar</type> </dependency> </dependencies> @@ -32,20 +33,20 @@ <version>0.3-incubating-SNAPSHOT</version> <configuration> <sourcePaths> - <sourcePath>target/test-classes/streams-schemas/activity.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/collection.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/media_link.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/object.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/objectTypes</sourcePath> - <sourcePath>target/test-classes/streams-schemas/verbs</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/activity.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/collection.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/media_link.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/object.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/objectTypes</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/verbs</sourcePath> </sourcePaths> - <targetDirectory>target/generated-resources/test-mojo</targetDirectory> + <targetDirectory>target/generated-resources/hbase-mojo</targetDirectory> <columnFamily>cf</columnFamily> </configuration> <executions> <execution> <goals> - <goal>hbase</goal> + <goal>generate-resources</goal> </goals> </execution> </executions> @@ -56,9 +57,9 @@ <version>2.10</version> <configuration> <includes>**/*.json</includes> - <outputDirectory>${project.build.directory}/test-classes/streams-schemas</outputDirectory> + <outputDirectory>${project.build.directory}/test-classes/streams-schema-activitystreams</outputDirectory> <includeGroupIds>org.apache.streams</includeGroupIds> - <includeArtifactIds>streams-schemas</includeArtifactIds> + <includeArtifactIds>streams-schema-activitystreams</includeArtifactIds> <includeTypes>jar,test-jar</includeTypes> </configuration> <executions> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/pom.xml b/streams-plugins/streams-plugin-hive/pom.xml index 515314a..38c69c1 100644 --- a/streams-plugins/streams-plugin-hive/pom.xml +++ b/streams-plugins/streams-plugin-hive/pom.xml @@ -54,10 +54,17 @@ </dependency> <dependency> <groupId>org.apache.streams</groupId> - <artifactId>streams-schemas</artifactId> + <artifactId>streams-util</artifactId> <version>${project.version}</version> </dependency> <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-schema-activitystreams</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> @@ -230,9 +237,9 @@ </goals> <configuration> <includeGroupIds>org.apache.streams</includeGroupIds> - <includeArtifactIds>streams-schemas</includeArtifactIds> + <includeArtifactIds>streams-schema-activitystreams</includeArtifactIds> <includes>**/*.json</includes> - <outputDirectory>${project.build.directory}/test-classes/streams-schemas</outputDirectory> + <outputDirectory>${project.build.directory}/test-classes/streams-schema-activitystreams</outputDirectory> </configuration> </execution> </executions> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveGenerationConfig.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveGenerationConfig.java b/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveGenerationConfig.java index 7e3bf35..f957757 100644 --- a/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveGenerationConfig.java +++ b/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveGenerationConfig.java @@ -1,11 +1,10 @@ package org.apache.streams.plugins.hive; -import org.apache.streams.schema.GenerationConfig; +import org.apache.streams.util.schema.GenerationConfig; import org.jsonschema2pojo.DefaultGenerationConfig; import org.jsonschema2pojo.util.URLUtil; import java.io.File; -import java.io.FileFilter; import java.net.URL; import java.util.ArrayList; import java.util.Collections; http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGenerator.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGenerator.java b/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGenerator.java index c09f7dd..60c59ca 100644 --- a/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGenerator.java +++ b/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGenerator.java @@ -1,33 +1,29 @@ package org.apache.streams.plugins.hive; -import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.Lists; -import org.apache.streams.schema.FieldType; -import org.apache.streams.schema.FieldUtil; -import org.apache.streams.schema.FileUtil; -import org.apache.streams.schema.GenerationConfig; -import org.apache.streams.schema.Schema; -import org.apache.streams.schema.SchemaStore; -import org.apache.streams.schema.SchemaUtil; -import org.apache.streams.schema.URIUtil; +import org.apache.streams.util.schema.FieldType; +import org.apache.streams.util.schema.FieldUtil; +import org.apache.streams.util.schema.FileUtil; +import org.apache.streams.util.schema.GenerationConfig; +import org.apache.streams.util.schema.Schema; +import org.apache.streams.util.schema.SchemaStore; +import org.apache.streams.util.schema.SchemaStoreImpl; import org.jsonschema2pojo.util.URLUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.net.URI; import java.net.URL; import java.util.*; import static com.google.common.base.Preconditions.checkNotNull; import static org.apache.commons.lang3.StringUtils.defaultString; -import static org.apache.streams.schema.FileUtil.*; +import static org.apache.streams.util.schema.FileUtil.*; /** * Generates hive table definitions for using org.openx.data.jsonserde.JsonSerDe on new-line delimited json documents. @@ -42,7 +38,7 @@ public class StreamsHiveResourceGenerator implements Runnable { private StreamsHiveGenerationConfig config; - private SchemaStore schemaStore = new SchemaStore(); + private SchemaStore schemaStore = new SchemaStoreImpl(); private int currentDepth = 0; @@ -60,17 +56,8 @@ public class StreamsHiveResourceGenerator implements Runnable { config.setSourceDirectory(sourceDirectory); config.setTargetDirectory(targetDirectory); - StreamsHiveResourceGenerator streamsPojoSourceGenerator = new StreamsHiveResourceGenerator(config); - Thread thread = new Thread(streamsPojoSourceGenerator); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - } - return; + StreamsHiveResourceGenerator streamsHiveResourceGenerator = new StreamsHiveResourceGenerator(config); + streamsHiveResourceGenerator.run(); } public StreamsHiveResourceGenerator(StreamsHiveGenerationConfig config) { http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGeneratorMojo.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGeneratorMojo.java b/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGeneratorMojo.java index 16466cf..76e3a18 100644 --- a/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGeneratorMojo.java +++ b/streams-plugins/streams-plugin-hive/src/main/java/org/apache/streams/plugins/hive/StreamsHiveResourceGeneratorMojo.java @@ -15,10 +15,10 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.util.List; -@Mojo( name = "hive", +@Mojo( name = "generate-resources", defaultPhase = LifecyclePhase.GENERATE_RESOURCES ) -@Execute( goal = "hive", +@Execute( goal = "generate-resources", phase = LifecyclePhase.GENERATE_RESOURCES ) public class StreamsHiveResourceGeneratorMojo extends AbstractMojo { @@ -30,15 +30,6 @@ public class StreamsHiveResourceGeneratorMojo extends AbstractMojo { @Component private MavenProject project; -// @Component -// private Settings settings; -// -// @Parameter( defaultValue = "${localRepository}", readonly = true, required = true ) -// protected ArtifactRepository localRepository; -// -// @Parameter( defaultValue = "${plugin}", readonly = true ) // Maven 3 only -// private PluginDescriptor plugin; -// @Parameter( defaultValue = "${project.basedir}", readonly = true ) private File basedir; @@ -65,29 +56,8 @@ public class StreamsHiveResourceGeneratorMojo extends AbstractMojo { StreamsHiveResourceGenerator streamsHiveResourceGenerator = new StreamsHiveResourceGenerator(config); - Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() { - public void uncaughtException(Thread th, Throwable ex) { - LOGGER.error("Exception", ex); - mojoFailureException = new MojoFailureException("Exception", ex); - } - }; - Thread.setDefaultUncaughtExceptionHandler(h); - Thread thread = new Thread(streamsHiveResourceGenerator); - thread.setUncaughtExceptionHandler(h); - try { - thread.start(); - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - mojoFailureException = new MojoFailureException("Exception", e); - } - - if( mojoFailureException != null ) - throw mojoFailureException; - - return; + streamsHiveResourceGenerator.run(); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/src/site/markdown/index.md ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/site/markdown/index.md b/streams-plugins/streams-plugin-hive/src/site/markdown/index.md index 4df9103..12ce831 100644 --- a/streams-plugins/streams-plugin-hive/src/site/markdown/index.md +++ b/streams-plugins/streams-plugin-hive/src/site/markdown/index.md @@ -3,18 +3,36 @@ org.apache.streams.plugins:streams-plugin-hive streams-plugin-hive generates resources from json schemas to assist with analysis of json data using Apache Hive. -#### Usage +### Usage -Run within a module containing a src/main/jsonschema directory +Output will be placed in target/generated-resources/hive by default - mvn org.apache.streams.plugins:streams-plugin-hive:0.3-incubating-SNAPSHOT:hive +##### Maven -Output will be placed in target/generated-resources/hive by default +Run within a module containing a src/main/jsonschema directory -#### Example + mvn org.apache.streams.plugins:streams-plugin-hive:0.3-incubating-SNAPSHOT:generate-resources [streams-plugin-hive/pom.xml](streams-plugin-hive/pom.xml "streams-plugin-hive/pom.xml") +##### SDK + +Embed within your own java code + + StreamsHiveGenerationConfig config = new StreamsHiveGenerationConfig(); + config.setSourceDirectory("src/main/jsonschema"); + config.setTargetDirectory("target/generated-resources"); + StreamsHiveGenerationConfig generator = new StreamsHiveGenerationConfig(config); + generator.run(); + +##### CLI + +Run from CLI without Maven + + java -jar streams-plugin-hive-jar-with-dependencies.jar StreamsHiveResourceGenerator src/main/jsonschema target/generated-resources + +#### Example + #### Documentation [JavaDocs](apidocs/index.html "JavaDocs") http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java index 21c82f9..ed08c31 100644 --- a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java +++ b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java @@ -21,7 +21,7 @@ public class StreamsHiveResourceGeneratorCLITest { @Test public void testStreamsHiveResourceGeneratorCLI() throws Exception { - String sourceDirectory = "target/test-classes/streams-schemas"; + String sourceDirectory = "target/test-classes/streams-schema-activitystreams"; String targetDirectory = "target/generated-resources/hive-cli"; List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java index b2f3e14..e2fbecc 100644 --- a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java +++ b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java @@ -50,7 +50,7 @@ public class StreamsHiveResourceGeneratorMojoTest extends TestCase { verifier.resetStreams(); - File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/test-mojo"); + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/hive-mojo"); assert( testOutput != null ); assert( testOutput.exists() == true ); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java index 3944ddf..9778bb6 100644 --- a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java +++ b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java @@ -18,7 +18,7 @@ import java.io.File; import java.util.Collection; import java.util.Iterator; -import static org.apache.streams.schema.FileUtil.dropSourcePathPrefix; +import static org.apache.streams.util.schema.FileUtil.dropSourcePathPrefix; /** * Test that Activity beans are compatible with the example activities in the spec. @@ -47,26 +47,18 @@ public class StreamsHiveResourceGeneratorTest { StreamsHiveGenerationConfig config = new StreamsHiveGenerationConfig(); - String sourceDirectory = "target/test-classes/streams-schemas"; + String sourceDirectory = "target/test-classes/streams-schema-activitystreams"; config.setSourceDirectory(sourceDirectory); - config.setTargetDirectory("target/generated-sources/test"); + config.setTargetDirectory("target/generated-resources/test"); config.setExclusions(Sets.newHashSet("attachments")); config.setMaxDepth(2); StreamsHiveResourceGenerator streamsHiveResourceGenerator = new StreamsHiveResourceGenerator(config); - Thread thread = new Thread(streamsHiveResourceGenerator); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - } + streamsHiveResourceGenerator.run(); File testOutput = config.getTargetDirectory(); @@ -106,19 +98,5 @@ public class StreamsHiveResourceGeneratorTest { LOGGER.info("Fails: {}", fails); Assert.fail(); } - - -// assert( new File(testOutput + "/traits").exists() == true ); -// assert( new File(testOutput + "/traits").isDirectory() == true ); -// assert( new File(testOutput + "/traits").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/traits").listFiles(scalaFilter).length == 4 ); -// assert( new File(testOutput + "/objectTypes").exists() == true ); -// assert( new File(testOutput + "/objectTypes").isDirectory() == true ); -// assert( new File(testOutput + "/objectTypes").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/objectTypes").listFiles(scalaFilter).length == 43 ); -// assert( new File(testOutput + "/verbs").exists() == true ); -// assert( new File(testOutput + "/verbs").isDirectory() == true ); -// assert( new File(testOutput + "/verbs").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/verbs").listFiles(scalaFilter).length == 89 ); - } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-hive/src/test/resources/streams-plugin-hive/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/test/resources/streams-plugin-hive/pom.xml b/streams-plugins/streams-plugin-hive/src/test/resources/streams-plugin-hive/pom.xml index ae4bb66..40931ae 100644 --- a/streams-plugins/streams-plugin-hive/src/test/resources/streams-plugin-hive/pom.xml +++ b/streams-plugins/streams-plugin-hive/src/test/resources/streams-plugin-hive/pom.xml @@ -18,9 +18,10 @@ </dependency> <dependency> <groupId>org.apache.streams</groupId> - <artifactId>streams-schemas</artifactId> + <artifactId>streams-schema-activitystreams</artifactId> <version>${project.version}</version> <scope>test</scope> + <type>test-jar</type> </dependency> </dependencies> @@ -32,19 +33,19 @@ <version>0.3-incubating-SNAPSHOT</version> <configuration> <sourcePaths> - <sourcePath>target/test-classes/streams-schemas/activity.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/collection.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/media_link.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/object.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/objectTypes</sourcePath> - <sourcePath>target/test-classes/streams-schemas/verbs</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/activity.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/collection.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/media_link.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/object.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/objectTypes</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/verbs</sourcePath> </sourcePaths> - <targetDirectory>target/generated-resources/test-mojo</targetDirectory> + <targetDirectory>target/generated-resources/hive-mojo</targetDirectory> </configuration> <executions> <execution> <goals> - <goal>hive</goal> + <goal>generate-resources</goal> </goals> </execution> </executions> @@ -55,9 +56,9 @@ <version>2.10</version> <configuration> <includes>**/*.json</includes> - <outputDirectory>${project.build.directory}/test-classes/streams-schemas</outputDirectory> + <outputDirectory>${project.build.directory}/test-classes/streams-schema-activitystreams</outputDirectory> <includeGroupIds>org.apache.streams</includeGroupIds> - <includeArtifactIds>streams-schemas</includeArtifactIds> + <includeArtifactIds>streams-schema-activitystreams</includeArtifactIds> <includeTypes>jar,test-jar</includeTypes> </configuration> <executions> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/pom.xml b/streams-plugins/streams-plugin-pig/pom.xml index ef59587..0c7bf1a 100644 --- a/streams-plugins/streams-plugin-pig/pom.xml +++ b/streams-plugins/streams-plugin-pig/pom.xml @@ -54,10 +54,17 @@ </dependency> <dependency> <groupId>org.apache.streams</groupId> - <artifactId>streams-schemas</artifactId> + <artifactId>streams-util</artifactId> <version>${project.version}</version> </dependency> <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-schema-activitystreams</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> @@ -230,9 +237,9 @@ </goals> <configuration> <includeGroupIds>org.apache.streams</includeGroupIds> - <includeArtifactIds>streams-schemas</includeArtifactIds> + <includeArtifactIds>streams-schema-activitystreams</includeArtifactIds> <includes>**/*.json</includes> - <outputDirectory>${project.build.directory}/test-classes/streams-schemas</outputDirectory> + <outputDirectory>${project.build.directory}/test-classes/streams-schema-activitystreams</outputDirectory> </configuration> </execution> </executions> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigGenerationConfig.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigGenerationConfig.java b/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigGenerationConfig.java index 5aa55ed..1b346f4 100644 --- a/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigGenerationConfig.java +++ b/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigGenerationConfig.java @@ -1,11 +1,10 @@ package org.apache.streams.plugins.pig; -import org.apache.streams.schema.GenerationConfig; +import org.apache.streams.util.schema.GenerationConfig; import org.jsonschema2pojo.DefaultGenerationConfig; import org.jsonschema2pojo.util.URLUtil; import java.io.File; -import java.io.FileFilter; import java.net.URL; import java.util.ArrayList; import java.util.Collections; http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGenerator.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGenerator.java b/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGenerator.java index 072e1b6..f1f94a6 100644 --- a/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGenerator.java +++ b/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGenerator.java @@ -6,13 +6,13 @@ import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.Lists; -import org.apache.streams.plugins.pig.StreamsPigGenerationConfig; -import org.apache.streams.schema.FieldType; -import org.apache.streams.schema.FieldUtil; -import org.apache.streams.schema.FileUtil; -import org.apache.streams.schema.GenerationConfig; -import org.apache.streams.schema.Schema; -import org.apache.streams.schema.SchemaStore; +import org.apache.streams.util.schema.FieldType; +import org.apache.streams.util.schema.FieldUtil; +import org.apache.streams.util.schema.FileUtil; +import org.apache.streams.util.schema.GenerationConfig; +import org.apache.streams.util.schema.Schema; +import org.apache.streams.util.schema.SchemaStore; +import org.apache.streams.util.schema.SchemaStoreImpl; import org.jsonschema2pojo.util.URLUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,10 +25,10 @@ import java.util.List; import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; -import static org.apache.streams.schema.FileUtil.dropExtension; -import static org.apache.streams.schema.FileUtil.dropSourcePathPrefix; -import static org.apache.streams.schema.FileUtil.swapExtension; -import static org.apache.streams.schema.FileUtil.writeFile; +import static org.apache.streams.util.schema.FileUtil.dropExtension; +import static org.apache.streams.util.schema.FileUtil.dropSourcePathPrefix; +import static org.apache.streams.util.schema.FileUtil.swapExtension; +import static org.apache.streams.util.schema.FileUtil.writeFile; public class StreamsPigResourceGenerator implements Runnable { @@ -38,7 +38,7 @@ public class StreamsPigResourceGenerator implements Runnable { private StreamsPigGenerationConfig config; - private SchemaStore schemaStore = new SchemaStore(); + private SchemaStore schemaStore = new SchemaStoreImpl(); private int currentDepth = 0; @@ -57,16 +57,8 @@ public class StreamsPigResourceGenerator implements Runnable { config.setTargetDirectory(targetDirectory); StreamsPigResourceGenerator streamsPigResourceGenerator = new StreamsPigResourceGenerator(config); - Thread thread = new Thread(streamsPigResourceGenerator); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - } - return; + streamsPigResourceGenerator.run(); + } public StreamsPigResourceGenerator(StreamsPigGenerationConfig config) { @@ -160,13 +152,9 @@ public class StreamsPigResourceGenerator implements Runnable { if (fieldType != null ) { switch (fieldType) { case ARRAY: - ObjectNode itemsNode = FieldUtil.resolveItemsNode(fieldNode); - if( itemsNode == null ) { - ObjectNode resolvedItems = schemaStore.resolveProperties(schema, fieldNode, fieldId); - itemsNode = FieldUtil.resolveItemsNode(); - } - if( itemsNode != null && currentDepth <= config.getMaxDepth()) { - StringBuilder arrayItemsBuilder = appendArrayItems(new StringBuilder(), schema, fieldId, itemsNode, seperator); + ObjectNode resolvedItems = schemaStore.resolveItems(schema, fieldNode, fieldId); + if( resolvedItems != null && currentDepth <= config.getMaxDepth()) { + StringBuilder arrayItemsBuilder = appendArrayItems(new StringBuilder(), schema, fieldId, resolvedItems, seperator); if( !Strings.isNullOrEmpty(arrayItemsBuilder.toString())) { fieldStrings.add(arrayItemsBuilder.toString()); } http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGeneratorMojo.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGeneratorMojo.java b/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGeneratorMojo.java index 4763b60..571c75a 100644 --- a/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGeneratorMojo.java +++ b/streams-plugins/streams-plugin-pig/src/main/java/org/apache/streams/plugins/pig/StreamsPigResourceGeneratorMojo.java @@ -15,10 +15,10 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.util.List; -@Mojo( name = "pig", +@Mojo( name = "generate-resources", defaultPhase = LifecyclePhase.GENERATE_RESOURCES ) -@Execute( goal = "pig", +@Execute( goal = "generate-resources", phase = LifecyclePhase.GENERATE_RESOURCES ) public class StreamsPigResourceGeneratorMojo extends AbstractMojo { @@ -30,15 +30,6 @@ public class StreamsPigResourceGeneratorMojo extends AbstractMojo { @Component private MavenProject project; -// @Component -// private Settings settings; -// -// @Parameter( defaultValue = "${localRepository}", readonly = true, required = true ) -// protected ArtifactRepository localRepository; -// -// @Parameter( defaultValue = "${plugin}", readonly = true ) // Maven 3 only -// private PluginDescriptor plugin; -// @Parameter( defaultValue = "${project.basedir}", readonly = true ) private File basedir; @@ -64,30 +55,7 @@ public class StreamsPigResourceGeneratorMojo extends AbstractMojo { config.setTargetDirectory(targetDirectory); StreamsPigResourceGenerator streamsPigResourceGenerator = new StreamsPigResourceGenerator(config); - - Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() { - public void uncaughtException(Thread th, Throwable ex) { - LOGGER.error("Exception", ex); - mojoFailureException = new MojoFailureException("Exception", ex); - } - }; - Thread.setDefaultUncaughtExceptionHandler(h); - Thread thread = new Thread(streamsPigResourceGenerator); - thread.setUncaughtExceptionHandler(h); - try { - thread.start(); - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - mojoFailureException = new MojoFailureException("Exception", e); - } - - if( mojoFailureException != null ) - throw mojoFailureException; - - return; + streamsPigResourceGenerator.run(); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/src/site/markdown/index.md ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/site/markdown/index.md b/streams-plugins/streams-plugin-pig/src/site/markdown/index.md index d0d4791..5ab4375 100644 --- a/streams-plugins/streams-plugin-pig/src/site/markdown/index.md +++ b/streams-plugins/streams-plugin-pig/src/site/markdown/index.md @@ -3,17 +3,33 @@ org.apache.streams.plugins:streams-plugin-pig streams-plugin-pig generates resources from json schemas to assist with analysis of json data using Apache Pig. -#### Usage +### Usage + +Output will be placed in target/generated-resources/pig by default + +##### Maven Run within a module containing a src/main/jsonschema directory mvn org.apache.streams.plugins:streams-plugin-pig:0.3-incubating-SNAPSHOT:pig -Output will be placed in target/generated-resources/pig by default +[streams-plugin-pig/pom.xml](streams-plugin-pig/pom.xml "streams-plugin-pig/pom.xml") -#### Example +##### SDK -[streams-plugin-pig/pom.xml](streams-plugin-pig/pom.xml "streams-plugin-pig/pom.xml") +Embed within your own java code + + StreamsPigGenerationConfig config = new StreamsPigGenerationConfig(); + config.setSourceDirectory("src/main/jsonschema"); + config.setTargetDirectory("target/generated-resources"); + StreamsPigGenerationConfig generator = new StreamsPigGenerationConfig(config); + generator.run(); + +##### CLI + +Run from CLI without Maven + + java -jar streams-plugin-pig-jar-with-dependencies.jar StreamsPigResourceGenerator src/main/jsonschema target/generated-resources #### Documentation http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java index c94bca9..8190d50 100644 --- a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java +++ b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java @@ -19,8 +19,8 @@ public class StreamsPigResourceGeneratorCLITest { @Test public void testStreamsPigResourceGeneratorCLI() throws Exception { - String sourceDirectory = "target/test-classes/streams-schemas"; - String targetDirectory = "target/generated-resources/hive-cli"; + String sourceDirectory = "target/test-classes/streams-schema-activitystreams"; + String targetDirectory = "target/generated-resources/pig-cli"; List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory); StreamsPigResourceGenerator.main(argsList.toArray(new String[0])); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java index 401c506..76c4eb2 100644 --- a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java +++ b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java @@ -31,7 +31,7 @@ public class StreamsPigResourceGeneratorMojoTest extends TestCase { @Test - public void testStreamsHiveResourceGeneratorMojo() throws Exception { + public void testStreamsPigResourceGeneratorMojo() throws Exception { File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-pig" ); @@ -50,7 +50,7 @@ public class StreamsPigResourceGeneratorMojoTest extends TestCase { verifier.resetStreams(); - File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/test-mojo"); + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/pig-mojo"); assert( testOutput != null ); assert( testOutput.exists() == true ); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java index a1ab281..98442ad 100644 --- a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java +++ b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java @@ -17,7 +17,7 @@ import java.io.File; import java.util.Collection; import java.util.Iterator; -import static org.apache.streams.schema.FileUtil.dropSourcePathPrefix; +import static org.apache.streams.util.schema.FileUtil.dropSourcePathPrefix; /** * Test that Activity beans are compatible with the example activities in the spec. @@ -45,28 +45,20 @@ public class StreamsPigResourceGeneratorTest { StreamsPigGenerationConfig config = new StreamsPigGenerationConfig(); - String sourceDirectory = "target/test-classes/streams-schemas"; + String sourceDirectory = "target/test-classes/streams-schema-activitystreams"; config.setSourceDirectory(sourceDirectory); - config.setTargetDirectory("target/generated-sources/test"); + config.setTargetDirectory("target/generated-resources/pig"); config.setExclusions(Sets.newHashSet("attachments")); config.setMaxDepth(2); StreamsPigResourceGenerator streamsPigResourceGenerator = new StreamsPigResourceGenerator(config); - Thread thread = new Thread(streamsPigResourceGenerator); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - } + streamsPigResourceGenerator.run(); - File testOutput = new File( "./target/generated-sources/test"); + File testOutput = config.getTargetDirectory(); assert( testOutput != null ); assert( testOutput.exists() == true ); @@ -104,19 +96,5 @@ public class StreamsPigResourceGeneratorTest { LOGGER.info("Fails: {}", fails); Assert.fail(); } - - -// assert( new File(testOutput + "/traits").exists() == true ); -// assert( new File(testOutput + "/traits").isDirectory() == true ); -// assert( new File(testOutput + "/traits").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/traits").listFiles(scalaFilter).length == 4 ); -// assert( new File(testOutput + "/objectTypes").exists() == true ); -// assert( new File(testOutput + "/objectTypes").isDirectory() == true ); -// assert( new File(testOutput + "/objectTypes").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/objectTypes").listFiles(scalaFilter).length == 43 ); -// assert( new File(testOutput + "/verbs").exists() == true ); -// assert( new File(testOutput + "/verbs").isDirectory() == true ); -// assert( new File(testOutput + "/verbs").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/verbs").listFiles(scalaFilter).length == 89 ); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pig/src/test/resources/streams-plugin-pig/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/test/resources/streams-plugin-pig/pom.xml b/streams-plugins/streams-plugin-pig/src/test/resources/streams-plugin-pig/pom.xml index 7027446..f3976fa 100644 --- a/streams-plugins/streams-plugin-pig/src/test/resources/streams-plugin-pig/pom.xml +++ b/streams-plugins/streams-plugin-pig/src/test/resources/streams-plugin-pig/pom.xml @@ -18,9 +18,10 @@ </dependency> <dependency> <groupId>org.apache.streams</groupId> - <artifactId>streams-schemas</artifactId> + <artifactId>streams-schema-activitystreams</artifactId> <version>${project.version}</version> <scope>test</scope> + <type>test-jar</type> </dependency> </dependencies> @@ -32,19 +33,19 @@ <version>0.3-incubating-SNAPSHOT</version> <configuration> <sourcePaths> - <sourcePath>target/test-classes/streams-schemas/activity.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/collection.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/media_link.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/object.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/objectTypes</sourcePath> - <sourcePath>target/test-classes/streams-schemas/verbs</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/activity.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/collection.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/media_link.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/object.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/objectTypes</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/verbs</sourcePath> </sourcePaths> - <targetDirectory>target/generated-resources/test-mojo</targetDirectory> + <targetDirectory>target/generated-resources/pig-mojo</targetDirectory> </configuration> <executions> <execution> <goals> - <goal>pig</goal> + <goal>generate-resources</goal> </goals> </execution> </executions> @@ -55,9 +56,9 @@ <version>2.10</version> <configuration> <includes>**/*.json</includes> - <outputDirectory>${project.build.directory}/test-classes/streams-schemas</outputDirectory> + <outputDirectory>${project.build.directory}/test-classes/streams-schema-activitystreams</outputDirectory> <includeGroupIds>org.apache.streams</includeGroupIds> - <includeArtifactIds>streams-schemas</includeArtifactIds> + <includeArtifactIds>streams-schema-activitystreams</includeArtifactIds> <includeTypes>jar,test-jar</includeTypes> </configuration> <executions> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pojo/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/pom.xml b/streams-plugins/streams-plugin-pojo/pom.xml index bfa3480..da7c0b2 100644 --- a/streams-plugins/streams-plugin-pojo/pom.xml +++ b/streams-plugins/streams-plugin-pojo/pom.xml @@ -44,10 +44,17 @@ </dependency> <dependency> <groupId>org.apache.streams</groupId> - <artifactId>streams-schemas</artifactId> + <artifactId>streams-util</artifactId> <version>${project.version}</version> </dependency> <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-schema-activitystreams</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.jsonschema2pojo</groupId> <artifactId>jsonschema2pojo-core</artifactId> <version>0.4.10</version> @@ -224,9 +231,9 @@ <artifactId>maven-dependency-plugin</artifactId> <configuration> <includes>**/*.json</includes> - <outputDirectory>${project.build.directory}/test-classes/streams-schemas</outputDirectory> + <outputDirectory>${project.build.directory}/test-classes/streams-schema-activitystreams</outputDirectory> <includeGroupIds>org.apache.streams</includeGroupIds> - <includeArtifactIds>streams-schemas</includeArtifactIds> + <includeArtifactIds>streams-schema-activitystreams</includeArtifactIds> <includeTypes>jar,test-jar</includeTypes> </configuration> <executions> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGenerator.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGenerator.java b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGenerator.java index f7b6617..504eb80 100644 --- a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGenerator.java +++ b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGenerator.java @@ -25,7 +25,7 @@ public class StreamsPojoSourceGenerator implements Runnable { StreamsPojoGenerationConfig config = new StreamsPojoGenerationConfig(); String sourceDirectory = "./target/test-classes/activities"; - String targetDirectory = "./target/generated-sources/streams-plugin-pojo"; + String targetDirectory = "./target/generated-sources/pojo"; String targetPackage = ""; if( args.length > 0 ) @@ -40,15 +40,8 @@ public class StreamsPojoSourceGenerator implements Runnable { config.setTargetDirectory(targetDirectory); StreamsPojoSourceGenerator streamsPojoSourceGenerator = new StreamsPojoSourceGenerator(config); - Thread thread = new Thread(streamsPojoSourceGenerator); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - } + streamsPojoSourceGenerator.run(); + return; } @@ -68,8 +61,6 @@ public class StreamsPojoSourceGenerator implements Runnable { } } - - private void writeFile(String pojoFile, String pojoHive) { try { File path = new File(pojoFile); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGeneratorMojo.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGeneratorMojo.java b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGeneratorMojo.java index 8cf1697..2a4978a 100644 --- a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGeneratorMojo.java +++ b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoSourceGeneratorMojo.java @@ -30,10 +30,10 @@ import java.util.List; import static org.apache.commons.lang.StringUtils.isNotBlank; -@Mojo( name = "pojo", +@Mojo( name = "generate-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES ) -@Execute( goal = "pojo", +@Execute( goal = "generate-sources", phase = LifecyclePhase.GENERATE_SOURCES ) public class StreamsPojoSourceGeneratorMojo extends AbstractMojo { @@ -45,16 +45,6 @@ public class StreamsPojoSourceGeneratorMojo extends AbstractMojo { @Component public MavenProject project; -// @Component -// private Settings settings; -// -// @Parameter( defaultValue = "${localRepository}", readonly = true, required = true ) -// protected ArtifactRepository localRepository; -// -// @Parameter( defaultValue = "${plugin}", readonly = true ) // Maven 3 only -// private PluginDescriptor plugin; -// - @Parameter( defaultValue = "${project.basedir}", readonly = true ) public File basedir; @@ -64,7 +54,7 @@ public class StreamsPojoSourceGeneratorMojo extends AbstractMojo { @Parameter( readonly = true ) // Maven 3 only public List<String> sourcePaths; - @Parameter(defaultValue = "./target/generated-sources/streams-plugin-pojo", readonly = true) + @Parameter(defaultValue = "./target/generated-sources/pojo", readonly = true) public String targetDirectory; @Parameter(readonly = true) @@ -84,30 +74,7 @@ public class StreamsPojoSourceGeneratorMojo extends AbstractMojo { config.setTargetDirectory(targetDirectory); StreamsPojoSourceGenerator streamsPojoSourceGenerator = new StreamsPojoSourceGenerator(config); - - Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() { - public void uncaughtException(Thread th, Throwable ex) { - LOGGER.error("Exception", ex); - mojoFailureException = new MojoFailureException("Exception", ex); - } - }; - Thread.setDefaultUncaughtExceptionHandler(h); - Thread thread = new Thread(streamsPojoSourceGenerator); - thread.setUncaughtExceptionHandler(h); - try { - thread.start(); - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - throw new MojoFailureException("Exception", e); - } - - if( mojoFailureException != null ) - throw mojoFailureException; - - return; + streamsPojoSourceGenerator.run(); } @@ -125,117 +92,4 @@ public class StreamsPojoSourceGeneratorMojo extends AbstractMojo { } -// public List<Class<?>> detectSerializableClasses() { -// -// Set<Class<? extends Serializable>> classes = -// reflections.getSubTypesOf(java.io.Serializable.class); -// -// List<Class<?>> result = Lists.newArrayList(); -// -// for( Class clazz : classes ) { -// result.add(clazz); -// } -// -// return result; -// } -// -// public List<Class<?>> detectPojoClasses(List<Class<?>> classes) { -// -// List<Class<?>> result = Lists.newArrayList(); -// -// for( Class clazz : classes ) { -// try { -// clazz.newInstance().toString(); -// } catch( Exception e) {} -// // super-halfass way to know if this is a jsonschema2pojo -// if( clazz.getAnnotations().length >= 1 ) -// result.add(clazz); -// } -// -// return result; -// } -// -// public String renderPojo(Class<?> pojoClass) { -// StringBuffer stringBuffer = new StringBuffer(); -// stringBuffer.append("CREATE TABLE "); -// stringBuffer.append(pojoClass.getPackage().getName().replace(".pojo.json", ".hive")); -// stringBuffer.append(LS); -// stringBuffer.append("("); -// stringBuffer.append(LS); -// -// Set<Field> fields = ReflectionUtils.getAllFields(pojoClass); -// appendFields(stringBuffer, fields, "", ","); -// -// stringBuffer.append(")"); -// -// return stringBuffer.toString(); -// } -// -// private void appendFields(StringBuffer stringBuffer, Set<Field> fields, String varDef, String fieldDelimiter) { -// if( fields.size() > 0 ) { -// stringBuffer.append(LS); -// Map<String,Field> fieldsToAppend = uniqueFields(fields); -// for( Iterator<Field> iter = fieldsToAppend.values().iterator(); iter.hasNext(); ) { -// Field field = iter.next(); -// stringBuffer.append(name(field)); -// stringBuffer.append(": "); -// stringBuffer.append(type(field)); -// if( iter.hasNext()) stringBuffer.append(fieldDelimiter); -// stringBuffer.append(LS); -// } -// } else { -// stringBuffer.append(LS); -// } -// } -// -// private String value(Field field) { -// if( field.getName().equals("verb")) { -// return "\"post\""; -// } else if( field.getName().equals("objectType")) { -// return "\"application\""; -// } else return null; -// } -// -// private String type(Field field) { -// if( field.getType().equals(java.lang.String.class)) { -// return "STRING"; -// } else if( field.getType().equals(java.lang.Integer.class)) { -// return "INT"; -// } else if( field.getType().equals(org.joda.time.DateTime.class)) { -// return "DATE"; -// }else if( field.getType().equals(java.util.Map.class)) { -// return "MAP"; -// } else if( field.getType().equals(java.util.List.class)) { -// return "ARRAY"; -// } -// return field.getType().getCanonicalName().replace(".pojo.json", ".scala"); -// } -// -// private Map<String,Field> uniqueFields(Set<Field> fieldset) { -// Map<String,Field> fields = Maps.newTreeMap(); -// Field item = null; -// for( Iterator<Field> it = fieldset.iterator(); it.hasNext(); item = it.next() ) { -// if( item != null && item.getName() != null ) { -// Field added = fields.put(item.getName(), item); -// } -// // ensure right class will get used -// } -// return fields; -// } -// -// private String name(Field field) { -// if( field.getName().equals("object")) -// return "obj"; -// else return field.getName(); -// } -// -// private boolean override(Field field) { -// try { -// if( field.getDeclaringClass().getSuperclass().getField(field.getName()) != null ) -// return true; -// else return false; -// } catch( Exception e ) { -// return false; -// } -// } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pojo/src/site/markdown/index.md ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/site/markdown/index.md b/streams-plugins/streams-plugin-pojo/src/site/markdown/index.md index d1bd848..996fa86 100644 --- a/streams-plugins/streams-plugin-pojo/src/site/markdown/index.md +++ b/streams-plugins/streams-plugin-pojo/src/site/markdown/index.md @@ -3,17 +3,33 @@ org.apache.streams.plugins:streams-plugin-pojo streams-plugin-pojo generates source files from json schemas suitable for writing Apache Streams components and libraries in Java. -#### Usage +### Usage + +Output will be placed in target/generated-sources/pojo by default + +##### Maven Run within a module containing a src/main/jsonschema directory mvn org.apache.streams.plugins:streams-plugin-pojo:0.3-incubating-SNAPSHOT:pojo -Output will be placed in target/generated-sources/pojo by default +[streams-plugin-pojo/pom.xml](streams-plugin-pojo/pom.xml "streams-plugin-pojo/pom.xml") -#### Example +##### SDK -[streams-plugin-pojo/pom.xml](streams-plugin-pojo/pom.xml "streams-plugin-pojo/pom.xml") +Embed within your own java code + + StreamsPojoGenerationConfig config = new StreamsPojoGenerationConfig(); + config.setSourceDirectory("src/main/jsonschema"); + config.setTargetDirectory("target/generated-resources"); + StreamsPojoSourceGenerator generator = new StreamsPojoSourceGenerator(config); + generator.run(); + +##### CLI + +Run from CLI without Maven + + java -jar streams-plugin-pojo-jar-with-dependencies.jar StreamsPojoSourceGenerator src/main/jsonschema target/generated-sources #### Documentation http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java index f808b28..07049ed 100644 --- a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java +++ b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java @@ -23,7 +23,7 @@ public class StreamsPojoSourceGeneratorCLITest { @Test public void testStreamsPojoSourceGeneratorCLI() throws Exception { - String sourceDirectory = "target/test-classes/streams-schemas"; + String sourceDirectory = "target/test-classes/streams-schema-activitystreams"; String targetDirectory = "target/generated-sources/test-cli"; List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java index 1968d90..41d762d 100644 --- a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java +++ b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java @@ -53,7 +53,7 @@ public class StreamsPojoSourceGeneratorMojoTest extends TestCase { verifier.resetStreams(); - File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-sources/test-mojo"); + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-sources/pojo-mojo"); assert( testOutput != null ); assert( testOutput.exists() == true ); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorTest.java b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorTest.java index 8d904af..6e7400e 100644 --- a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorTest.java +++ b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorTest.java @@ -43,53 +43,30 @@ public class StreamsPojoSourceGeneratorTest { StreamsPojoGenerationConfig config = new StreamsPojoGenerationConfig(); List<String> sourcePaths = Lists.newArrayList( - "target/test-classes/streams-schemas/activity.json", - "target/test-classes/streams-schemas/collection.json", - "target/test-classes/streams-schemas/media_link.json", - "target/test-classes/streams-schemas/object.json", - "target/test-classes/streams-schemas/objectTypes", - "target/test-classes/streams-schemas/verbs" + "target/test-classes/streams-schema-activitystreams/activity.json", + "target/test-classes/streams-schema-activitystreams/collection.json", + "target/test-classes/streams-schema-activitystreams/media_link.json", + "target/test-classes/streams-schema-activitystreams/object.json", + "target/test-classes/streams-schema-activitystreams/objectTypes", + "target/test-classes/streams-schema-activitystreams/verbs" ); config.setSourcePaths(sourcePaths); // config.setSourceDirectory("target/test-classes/streams-schemas"); - config.setTargetPackage("org.apache.streams.pojo.test"); - config.setTargetDirectory("target/generated-sources/test"); + config.setTargetPackage("org.apache.streams.pojo"); + config.setTargetDirectory("target/generated-sources/pojo"); StreamsPojoSourceGenerator streamsPojoSourceGenerator = new StreamsPojoSourceGenerator(config); - Thread thread = new Thread(streamsPojoSourceGenerator); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException", e); - } catch (Exception e) { - LOGGER.error("Exception", e); - } - - File testOutput = new File( "target/generated-sources/test"); + streamsPojoSourceGenerator.run(); - assert( testOutput != null ); - assert( testOutput.exists() == true ); - assert( testOutput.isDirectory() == true ); + assert( config.getTargetDirectory() != null ); + assert( config.getTargetDirectory().exists() == true ); + assert( config.getTargetDirectory().isDirectory() == true ); - Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) + Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(config.getTargetDirectory()) .filter(javaFilter); Collection<File> outputCollection = Lists.newArrayList(outputIterator); assert( outputCollection.size() > 133 ); -// assert( testOutput.listFiles(javaFilter).length == 11 ); -// assert( new File(testOutput + "/traits").exists() == true ); -// assert( new File(testOutput + "/traits").isDirectory() == true ); -// assert( new File(testOutput + "/traits").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/traits").listFiles(scalaFilter).length == 4 ); -// assert( new File(testOutput + "/objectTypes").exists() == true ); -// assert( new File(testOutput + "/objectTypes").isDirectory() == true ); -// assert( new File(testOutput + "/objectTypes").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/objectTypes").listFiles(scalaFilter).length == 43 ); -// assert( new File(testO`utput + "/verbs").exists() == true ); -// assert( new File(testOutput + "/verbs").isDirectory() == true ); -// assert( new File(testOutput + "/verbs").listFiles(scalaFilter) != null ); -// assert( new File(testOutput + "/verbs").listFiles(scalaFilter).length == 89 ); - } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/d9674f7c/streams-plugins/streams-plugin-pojo/src/test/resources/streams-plugin-pojo/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/test/resources/streams-plugin-pojo/pom.xml b/streams-plugins/streams-plugin-pojo/src/test/resources/streams-plugin-pojo/pom.xml index 21fd50e..2ca3f7c 100644 --- a/streams-plugins/streams-plugin-pojo/src/test/resources/streams-plugin-pojo/pom.xml +++ b/streams-plugins/streams-plugin-pojo/src/test/resources/streams-plugin-pojo/pom.xml @@ -23,9 +23,15 @@ </dependency> <dependency> <groupId>org.apache.streams</groupId> - <artifactId>streams-schemas</artifactId> + <artifactId>streams-util</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-schema-activitystreams</artifactId> <version>${project.version}</version> <scope>test</scope> + <type>test-jar</type> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> @@ -62,20 +68,20 @@ <version>0.3-incubating-SNAPSHOT</version> <configuration> <sourcePaths> - <sourcePath>target/test-classes/streams-schemas/activity.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/collection.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/media_link.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/object.json</sourcePath> - <sourcePath>target/test-classes/streams-schemas/objectTypes</sourcePath> - <sourcePath>target/test-classes/streams-schemas/verbs</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/activity.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/collection.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/media_link.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/object.json</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/objectTypes</sourcePath> + <sourcePath>target/test-classes/streams-schema-activitystreams/verbs</sourcePath> </sourcePaths> - <targetPackage>org.apache.streams.pojo.testmojo</targetPackage> - <targetDirectory>target/generated-sources/test-mojo</targetDirectory> + <targetPackage>org.apache.streams.pojo.mojo</targetPackage> + <targetDirectory>target/generated-sources/pojo-mojo</targetDirectory> </configuration> <executions> <execution> <goals> - <goal>pojo</goal> + <goal>generate-sources</goal> </goals> </execution> </executions> @@ -86,9 +92,9 @@ <version>2.10</version> <configuration> <includes>**/*.json</includes> - <outputDirectory>${project.build.directory}/test-classes/streams-schemas</outputDirectory> + <outputDirectory>${project.build.directory}/test-classes/streams-schema-activitystreams</outputDirectory> <includeGroupIds>org.apache.streams</includeGroupIds> - <includeArtifactIds>streams-schemas</includeArtifactIds> + <includeArtifactIds>streams-schema-activitystreams</includeArtifactIds> <includeTypes>jar,test-jar</includeTypes> </configuration> <executions>