Kettle源码启动运行
Kettle源码运行环境如下:
windows10
Kettle 9.3.0.2
Java JDK 11
IntelliJ IDEA 2021.2.2 (Community Edition)
Maven 3.8.1(版本不需要太高 )
导入kettle到IDEA
可通过kettle的GIthub地址获取 kettle的克隆连接,或直接下载ZIP压缩包,将kettle导入到IDEA。
配置Maven
打开Preferences - Build、Execution、Deployment - Builder - Maven
配置Maven为自己下载的Maven 3.8.1,配置Maven的Settings.xml文件
kettle的所需依赖包,在国内没有镜像。需要配置(配置来自kettle源码使用说明):
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- This is the recommended settings.xml for development of Hitachi Vantara projects. -->
<!--
If your wish to mirror everything through pentaho-public's repo uncomment bellow. Not recommended
for external developers.
-->
<!--
<mirrors>
<mirror>
<id>pentaho-public</id>
<url>https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
-->
<localRepository>D:\mavendata-kettle</localRepository>
<!--
Don't forget to add setting-security.xml so that the password get's decrypted
-->
<servers>
<server>
<id>pentaho-public</id>
<username>devreaduser</username>
<password>{zIMyJWfHKfoHiBJAVsAgW4E5BcJzR+nhTtgPy0J+/rs=}</password>
</server>
</servers>
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>pentaho-public</id>
<url>https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn/</url>
<mirrorOf>*</mirrorOf>
</mirror>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>�����ƹ����ֿ�</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<mirror>
<id>central-repository</id>
<mirrorOf>*</mirrorOf>
<name>Central Repository</name>
<url>http://central.maven.org/maven2/</url>
</mirror>
</mirrors>
<!--
You might want to tweak the 'updatePolicy' configuration to fit your need on having updated snapshots and
releases. Our recommendation is to set it to 'never' and run maven with the '-U' flag when needed.
-->
<profiles>
<profile>
<id>pentaho</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>pentaho-public</id>
<name>Pentaho Public</name>
<url>https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>pentaho-public</id>
<name>Pentaho Public</name>
<url>https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- this lets you call plugins from these groups in their short form -->
<pluginGroups>
<pluginGroup>org.pentaho.maven.plugins</pluginGroup>
<pluginGroup>com.pentaho.maven.plugins</pluginGroup>
<pluginGroup>com.github.spotbugs</pluginGroup>
</pluginGroups>
</settings>
配置完毕后,右击根pom - Maven - Reload project,等待Maven下载依赖
构建项目
依赖下载完毕后,点击IDEA右边Maven,点击“M”图标,运行命令【mvn clean install -DskipTests】,-DskipTests代表跳过测试
打印台出现一下字样,代表build已经完成了
此时到工程目录下的/assemblies/core/client/target地址
可以看到kettle的压缩包pdi-core-ce-9.3.0.0-SNAPSHOT.zip,解压后,可以看到Spoon.bat文件,在控制台执行定位到解压目录,执行【spoon.bat】即可在windows环境下启动kettle客户端。
在项目中调试kettle步骤:
启动Spoon.java
在以下路径中找到pentaho-kettle-master/ui/src/main/java/org/pentaho/di/ui/spoon/Spoon.java,右击,选择【run ‘Spoon.main()’】,启动它。
初次运行时,会运行失败,接下来按下面操作进行解决。
第一个错误失败截图如下:
java.lang.UnsatisfiedLinkError: Could not load SWT library
解决方法:
修改一下UI 子模块的中的pom.xml文件改成Windows的swt包
<!-- Third-party dependencies -->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.swt</groupId>-->
<!-- <artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>4.3</version>
</dependency>
修改 file ->Project Structure -> Modules -> kettle-ui-swt -> Dependencies 中将如下图中所示:将windows的swt放在前面,先加载,后面的linux的swt的jar包就不会再加载(这个如果你是在linux系统下的话,就不用修改这些)然后修改 file ->Project Structure -> Modules -> kettle-ui-swt -> Dependencies 中将如下图中所示:将windows的swt放在前面,先加载,后面的linux的swt的jar包就不会再加载
第二个错误:
添加kettle-password-encoder-plugins.xml到/kettle-core/src/main/resources下
第三个错误
java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory
点击"Edit Configurations",打开"Run Debug Configurations"界面
VM options:–class-path=“lib” -XstartOnFirstThread
Working directory:后面追加 dist
在源码目录下新建目录 dist,在 dist 目录中新建子目录 lib 将之前编译成功的发布包 zip 中的 ui 目录解压至<源码目录>\dist 中 将之前编译成功的发布包 zip 中的 lib 目录下的以下 4 个 jar 文件拷贝到<源码目录>\lib 中
其中slf4j-nop-1.7.12.jar,需要到远程仓库下载:https://repo1.maven.org/maven2/org/slf4j/slf4j-nop/1.7.12/
第四个错误: