Skip to content

Commit

Permalink
Create java8-examples archetype module
Browse files Browse the repository at this point in the history
This archetype module is automatically generated during
the build process, and its dependencies and tests verified.
  • Loading branch information
kennknowles committed Nov 23, 2016
1 parent 0ab3337 commit bc9a495
Show file tree
Hide file tree
Showing 9 changed files with 562 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
target/
bin/

# Ignore generated archetypes
sdks/java/maven-archetypes/examples-java8/src/main/resources/archetype-resources/src/

# Ignore IntelliJ files.
.idea/
*.iml
Expand Down
82 changes: 82 additions & 0 deletions sdks/java/maven-archetypes/examples-java8/generate-sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash -ex
#
# 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.
#

# Updates the examples-java8 archetype to have selection of our examples
# for use in walkthroughs, etc.
#
# Usage: Invoke with no arguments from any working directory.

# The directory of this script. Assumes root of the maven-archetypes module.
HERE="$(dirname $0)"

# The directory of the examples-java and examples-java8 modules
EXAMPLES_ROOT="${HERE}/../../../../examples/java"
JAVA8_EXAMPLES_ROOT="${HERE}/../../../../examples/java8"

# The root of the examples archetype
ARCHETYPE_ROOT="${HERE}/src/main/resources/archetype-resources"

mkdir -p "$ARCHETYPE_ROOT/src/main/java"
mkdir -p "$ARCHETYPE_ROOT/src/test/java"

#
# Copy the Java 7 subset of the examples project verbatim.
#
rsync -a --exclude cookbook --exclude complete \
"${EXAMPLES_ROOT}"/src/main/java/org/apache/beam/examples/ \
"${ARCHETYPE_ROOT}/src/main/java"

rsync -a --exclude cookbook --exclude complete --exclude '*IT.java' \
"${EXAMPLES_ROOT}"/src/test/java/org/apache/beam/examples/ \
"${ARCHETYPE_ROOT}/src/test/java"

#
# Copy in MinimalWordCountJava8 and mobile gaming example
#
rsync -a \
"${JAVA8_EXAMPLES_ROOT}"/src/main/java/org/apache/beam/examples/ \
"${ARCHETYPE_ROOT}/src/main/java"

rsync -a \
"${JAVA8_EXAMPLES_ROOT}"/src/test/java/org/apache/beam/examples/ \
"${ARCHETYPE_ROOT}/src/test/java"


#
# Replace 'package org.apache.beam.examples' with 'package ${package}' in all Java code
#
find "${ARCHETYPE_ROOT}/src/main/java" -name '*.java' -print0 \
| xargs -0 sed -i.bak 's/^package org\.apache\.beam\.examples/package ${package}/g'

find "${ARCHETYPE_ROOT}/src/test/java" -name '*.java' -print0 \
| xargs -0 sed -i.bak 's/^package org\.apache\.beam\.examples/package ${package}/g'

#
# Replace 'import org.apache.beam.examples.' with 'import ${package}.' in all Java code
#
find "${ARCHETYPE_ROOT}/src/main/java" -name '*.java' -print0 \
| xargs -0 sed -i.bak 's/^import org\.apache\.beam\.examples/import ${package}/g'

find "${ARCHETYPE_ROOT}/src/test/java" -name '*.java' -print0 \
| xargs -0 sed -i.bak 's/^import org\.apache\.beam\.examples/import ${package}/g'

#
# The use of -i.bak is necessary for the above to work with both GNU and BSD sed.
# Delete the files now.
#
find "${ARCHETYPE_ROOT}/src" -name '*.bak' -delete
177 changes: 177 additions & 0 deletions sdks/java/maven-archetypes/examples-java8/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-maven-archetypes-parent</artifactId>
<version>0.4.0-incubating-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>beam-sdks-java-maven-archetypes-examples-java8</artifactId>
<name>Apache Beam :: SDKs :: Java :: Maven Archetypes :: Examples - Java 8</name>
<description>A Maven Archetype to create a project containing
example pipelines from the Apache Beam Java SDK, targeting Java 8.
</description>

<packaging>maven-archetype</packaging>

<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>2.4</version>
</extension>
</extensions>

<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.4</version>
<executions>
<!-- archetype-packaging above binds this plugin's goals as follows:
archetype:jar to the package phase,
archetype:integration-test to the integration-test phase,
archetype:update-local-catalog to the install phase.
We defer the integration-test goal to the install phase, since
this test actually depends on the core SDK to be installed. -->
<execution>
<id>default-integration-test</id>
<phase>install</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>generate-archetype-contents</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${project.basedir}/generate-sources.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<!--
These are the dependencies of the generated code. This enables
the include-what-you-use analysis to work on the archetype.
In alphabetical order by groupId, then artifactId.
-->
<dependencies>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-bigquery</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-pubsub</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-core</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-direct-java</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<archetype-descriptor
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
name="Google Cloud Dataflow Example Pipelines Archetype"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<fileSets>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>

<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/test/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>

0 comments on commit bc9a495

Please sign in to comment.