需要一个示例POM文件,用于在集成测试阶段运行Pentaho厨房/平移转换和作业

Sco*_*t C 6 pentaho pom.xml maven

我花了太多时间在谷歌和Pentaho论坛上寻找一个简单的例子,我认为这是一个常见的用例.我要求SE人员帮忙回答这个问题.

我有一个Java和Pentaho ETL工作混合的项目.我们希望使用maven 3构建,测试和部署这两种类型的项目.

我正在寻找一个示例POM,它将在集成测试阶段执行转换和作业(使用kitchen/pan,我假设).此外,如果可能的话,还有一个示例,用于测试数据库中的水壶作业(例如DBunit).到目前为止,这是我所掌握的信息.

正在进行的工作POM文件:

<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>
    <groupId>pentaho-example</groupId>
    <artifactId>pentaho-example</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>pentaho-example</name>
    <!--
        required by pentaho stuff to bring in the needed jars to run via
        command line for testing
    -->
    <repositories>
        <repository>
            <releases>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <id>pentaho-repo</id>
            <url>http://repo.pentaho.org/artifactory/pentaho/</url>
        </repository>
        <repository>
            <id>pentaho-third-party</id>
            <url>http://repo.pentaho.org/artifactory/third-party/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.7</version>
        </dependency>
        <dependency>
            <groupId>org.pentaho</groupId>
            <artifactId>core</artifactId>
            <version>4.2.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.2</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>project</descriptorRef>
                    </descriptorRefs>
                    <!--
                        <descriptors> <descriptor>src/assemble/etl-only.xml</descriptor>
                        </descriptors>
                    -->
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

有没有人有更多信息或示例POM来说明如何做到这一点?

TIA,

斯科特

Emi*_*enz 0

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <groupId>module-groupId</groupId>
    <artifactId>module-artifact-id</artifactId>
    <version>2.4.6-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>module-name</name>

    <modules>
        <module>...</module>
        <module>...</module>
        <module>...</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <eula-wrap_create-dist-phase />
        <eula-wrap_assign-deps-to-properties-phase />
        <mockito.version>1.10.19</mockito.version>
        <pentaho-metadata.version>7.1.0.0-12</pentaho-metadata.version>
        <eula-wrap_create-izpack-installer-jar-phase />
        <pdi.version>7.1.0.0-12</pdi.version>
        <eula-wrap_attach-dist-phase />
        <junit.version>4.12</junit.version>
        <jersey.version>1.19.1</jersey.version>
        <jsr311-api.version>1.1.1</jsr311-api.version>
    </properties>

    <dependencies>
        <!-- https://public.nexus.pentaho.org/content/groups/omni/ -->
        <dependency>
            <groupId>pentaho</groupId>
            <artifactId>mondrian</artifactId>
            <version>3.12.0.1-196</version>
        </dependency>
        <!-- https://public.nexus.pentaho.org/content/groups/omni/ -->
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>kettle-core</artifactId>
            <version>${pdi.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>xercesImpl</artifactId>
                    <groupId>xerces</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>commons-httpclient</artifactId>
                    <groupId>commons-httpclient</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>pentaho-kettle</groupId>
            <artifactId>kettle-engine</artifactId>
            <version>${pdi.version}</version>
        </dependency>
        <!--<dependency>
            <groupId>org.pentaho.di.plugins</groupId>
        <artifactId>pdi-core-plugins-impl</artifactId>
            <version>${pdi.version}</version>
        </dependency> -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.3</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>*</artifactId>
                    <groupId>*</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/xml-apis/xml-apis -->
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.4.01</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>25.0-jre</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.0.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz -->
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <version>2.2.1</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.0.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-math3</artifactId>
            <version>3.6.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.11.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.11.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.11.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-compress</artifactId>
            <version>1.18</version>
        </dependency>

    </dependencies>


    <!-- Build Settings -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.4.2</version>
                <configuration>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <releaseProfiles>releases</releaseProfiles>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>releases</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <version>2.8.2</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
Run Code Online (Sandbox Code Playgroud)

Java示例

import java.util.logging.Level;
import java.util.logging.Logger;

import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.job.Job;
import org.pentaho.di.job.JobMeta;
import org.pentaho.di.repository.Repository;

public class KettleJobExec {

    private static final Logger logger = Logger.getLogger(KettleJobExec.class.getName());

    public static void runJob(String jobPath) {
        try {
            //System.setProperty("KETTLE_HOME",PropertyManager.getInstance().getPropertyAsString(Constantes.KETTLE_HOME));
            Repository repository = null;

            logger.log(Level.INFO, "Kettle enviroment init");
            KettleEnvironment.init(false);

            logger.log(Level.INFO, "JobMeta creation: " + jobPath);
            JobMeta jobMeta = new JobMeta(jobPath, repository);

            logger.log(Level.INFO, "Job creation");
            Job job = new Job(repository, jobMeta);

            logger.log(Level.INFO, "Job start");
            job.start();

            logger.log(Level.INFO, "Job wait until finished");
            job.waitUntilFinished();

            if (job.getErrors() > 0) {
                throw new Exception("Error Executing Job: " + job.getStatus());
            }

            
        } catch (Exception e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
        } finally {
            logger.log(Level.INFO, "Kettle enviroment shutdown");
            KettleEnvironment.shutdown();
        }
    }

}
Run Code Online (Sandbox Code Playgroud)