Skip to content

Commit

Permalink
Autogenerate examples archetype during build
Browse files Browse the repository at this point in the history
  • Loading branch information
kennknowles committed Nov 23, 2016
1 parent bc9a495 commit d6aa36a
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 1,394 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,6 +7,7 @@ target/
bin/

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

# Ignore IntelliJ files.
Expand Down
Expand Up @@ -24,10 +24,13 @@
HERE="$(dirname $0)"

# The directory of the examples-java module
EXAMPLES_ROOT="${HERE}/../../../examples/java"
EXAMPLES_ROOT="${HERE}/../../../../examples/java"

# The root of the examples archetype
ARCHETYPE_ROOT="${HERE}/examples/src/main/resources/archetype-resources"
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 subset of the examples project verbatim.
Expand All @@ -44,16 +47,22 @@ rsync -a --exclude cookbook --exclude complete --exclude '*IT.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 's/^package org\.apache\.beam\.examples/package ${package}/g'
| 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 's/^package org\.apache\.beam\.examples/package ${package}/g'
| 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 's/^import org\.apache\.beam\.examples/import ${package}/g'
| 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 's/^import org\.apache\.beam\.examples/import ${package}/g'
| 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
27 changes: 25 additions & 2 deletions sdks/java/maven-archetypes/examples/pom.xml
Expand Up @@ -15,7 +15,9 @@
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">
<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>

Expand All @@ -29,7 +31,8 @@
<artifactId>beam-sdks-java-maven-archetypes-examples</artifactId>
<name>Apache Beam :: SDKs :: Java :: Maven Archetypes :: Examples</name>
<description>A Maven Archetype to create a project containing all the
example pipelines from the Apache Beam Java SDK.</description>
example pipelines from the Apache Beam Java SDK.
</description>

<packaging>maven-archetype</packaging>

Expand Down Expand Up @@ -65,7 +68,27 @@
</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>

<dependencies>
<dependency>
<groupId>org.apache.beam</groupId>
Expand Down
Expand Up @@ -81,24 +81,7 @@
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<goals><goal>analyze-only</goal></goals>
<configuration>
<!-- Ignore runtime-only dependencies in analysis -->
<ignoreNonCompile>true</ignoreNonCompile>
<failOnWarning>true</failOnWarning>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

</plugins>
</pluginManagement>
</build>

Expand Down

This file was deleted.

0 comments on commit d6aa36a

Please sign in to comment.