LoginSignup
0
0

More than 5 years have passed since last update.

Google Cloud DataflowでPipelineのjarファイルを作成して実行する

Posted at

Dataflowの公式ページではmvnやEclipseからPipelineジョブを実行する例はあるが、実運用を考えたとき、実行するノードでわざわざmavenを入れるとコンテナのサイズが増えたりするので、jarファイルから実行できる方が好ましいケースがある。
そこでmavenから実行可能なjarファイルを作成する方法を記載する。

実行可能なJARファイルをmavenで作成するには"maven-assembly-plugin"プラグインを"build"宣言に記載する必要がある。

pom.xml
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.4.1</version>
      <configuration>
      <!-- get all project dependencies -->
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
      <!-- MainClass in mainfest make a executable jar -->
      <archive>
        <manifest>
          <mainClass>com.mycompany.app.App</mainClass>
        </manifest>
      </archive>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id>
        <!-- bind to the packaging phase -->
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
    </plugin>
  </plugins>
</build>

以下のコマンドでJARファイルを作成

mvn package

下記コマンドで実行する。

java -jar xxx.jar --project={GCPプロジェクト}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0