关于kettle 5.1源码的打包
目录
下载
地址: https://github.com/pentaho/pentaho-kettle/tree/5.1
将zip文件解压,然后导入到Idea,导入后如下图所示,5.1的源码不是一个maven工程,所以下载源码不是很方便,所以就给他改成一个maven工程。
kettle-core变成maven工程
新建一个pom.xml
内容如下
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>5.1.0.0-753</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>commons-vfs</groupId>
<artifactId>commons-vfs</artifactId>
<version>20100924-pentaho</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0.1</version>
</dependency>
<dependency>
<groupId>com.wcohen</groupId>
<artifactId>com.wcohen.secondstring</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<dependency>
<groupId>org.scannotation</groupId>
<artifactId>scannotation</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>2.6.9</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>metastore</artifactId>
<version>5.1.0.0-752</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.commons</groupId>-->
<!--<artifactId>commons-parent</artifactId>-->
<!--<version>18</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.4.18.v20190429</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>jug</groupId>
<artifactId>jug-lgpl</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test-src</testSourceDirectory>
<plugins>
<!--
Bind the maven-assembly-plugin to the package phase
this will create a jar file without the storm dependencies
suitable for deployment to a cluster.
-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
下面详细说明下这个pom.xml,首先是如下这段,这是定义打成jar包的版本啊什么的,
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>5.1.0.0-753</version>
<packaging>jar</packaging>
至于引入的dependencies这块就不说了,这是一个漫长而痛苦的过程,因为我不知道怎么让这种不是maven的工程自动下载jar包,
看了build.xml还有其他的一些文档说明,可能需要连接kettle的仓库,(我没有VPN,搞不了国外的库,很慢,很慢,还经常断。)
所以上述引用的包都是一个个亲手试出来,唉,无知的苦。
接下来是下面的build节点,这是用来在右侧maven出install一下可以打成jar包的,
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test-src</testSourceDirectory>
<plugins>
<!--
Bind the maven-assembly-plugin to the package phase
this will create a jar file without the storm dependencies
suitable for deployment to a cluster.
-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
当然还有build里面的resources节点,这是将kettle-core的一系列配置文件打进包里,没有这个就打不进去,
<resources>
<resource>
<directory>src</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
kettle-engine变成maven
和core一样,新建pom.xml,但是我这里的jar包依赖没有补全,所以整个engine是打不成jar包的,好在我后面修改的东西是core处的源码,还好,还好。
下面是我试了很久没有补全的jar包依赖,
谁要是知道engine里面依赖哪些jar包和版本,告诉我一下。
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<version>5.1.0.0-753</version>
<properties>
<kettle.version>5.1.0.0-753</kettle.version>
</properties>
<dependencies>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>${kettle.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>8.5.20</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<artifactId>jfreechart</artifactId>
<groupId>org.jfree</groupId>
<version>1.0.19</version>
</dependency>
<dependency>
<groupId>org.pentaho.reporting.engine</groupId>
<artifactId>classic-core</artifactId>
<version>8.2.0.0-342</version>
</dependency>
<!--<dependency>-->
<!--<groupId>commons-net</groupId>-->
<!--<artifactId>commons-net</artifactId>-->
<!--<version>3.5</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.enterprisedt</groupId>
<artifactId>edtFTPj</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>trilead-ssh2</groupId>
<artifactId>trilead-ssh2</artifactId>
<version>build213</version>
</dependency>
<dependency>
<groupId>ftp4che</groupId>
<artifactId>ftp4che</artifactId>
<version>0.7.1</version>
</dependency>
<dependency>
<groupId>infobright</groupId>
<artifactId>infobright-core</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>commons-compiler</artifactId>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.odftoolkit</groupId>
<artifactId>odfdom-java</artifactId>
<version>0.8.6</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.jsendnsca</groupId>
<artifactId>jsendnsca</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>commons-math</groupId>
<artifactId>commons-math</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.force.api</groupId>
<artifactId>force-wsc</artifactId>
<version>36.0.0</version>
</dependency>
<dependency>
<groupId>com.force.api</groupId>
<artifactId>force-partner-api</artifactId>
<version>24.0.0</version>
</dependency>
<dependency>
<groupId>com.healthmarketscience.jackcess</groupId>
<artifactId>jackcess</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>6.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.syslog4j</groupId>
<artifactId>syslog4j</artifactId>
<version>0.9.46</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>mondrian</artifactId>
<version>9.3.0.0-157</version>
</dependency>
<!--<dependency>-->
<!--<groupId>jetty</groupId>-->
<!--<artifactId>org.mortbay.jetty</artifactId>-->
<!--<version>6.0.0alpha3</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.25</version>
</dependency>
<dependency>
<groupId>ascsapjco3wrp</groupId>
<artifactId>ascsapjco3wrp</artifactId>
<version>20100529</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test-src</testSourceDirectory>
<plugins>
<!--
Bind the maven-assembly-plugin to the package phase
this will create a jar file without the storm dependencies
suitable for deployment to a cluster.
-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>
打包
改了源码后只需要在下图处install一下,然后就很方便可以被引用了。
在别的工程里面,只需要按如下方式就可以引用自己修改的源码,
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>5.1.0.0-753</version>
</dependency>