记一次Kettle编译调试

1 前言

由于最近工作中要用到kettle,有可能要进行二次开发,所以很有必要对其进行进一步了解与学习,那么对源代码编译运行研究就必不可少
对于Kettle的简介网上资料很多,可以参考Kettle简介

2 编译过程

Kettle是Java开发的,并且是完全开源的,开源地址为
https://github.com/pentaho/pentaho-kettle
大家最好下载他的最新的稳定版本,目前9.5.0.0版本太新,并且Kettle官方仓库资源不全,笔者测试成功的版本为9.4.0.0-343,下载地址为
https://github.com/pentaho/pentaho-kettle/tree/9.4.0.0-343

备注:为什么是343版本,可以参考如下信息
https://repo.orl.eng.hitachivantara.com/ui/native/pnt-mvn/org/pentaho/pentaho-parent-pom/

3 出现的问题

3.1 编译问题

3.1.1 syslog4j版本不对,将0.9.46版本改成0.9.34
<syslog4j.version>0.9.46</syslog4j.version> 
3.1.2 org.eclipse.core:commands.jar.3.0.0找不到

可以直接修改本地仓库,在一个可用的commands版本上,修改其版本号,保证编译通过再说,如下图
在这里插入图片描述
笔者就是直接在3.3.0-I20070605-0010版本上做的修改

3.2 运行问题

3.2.1 org.eclipse.swt包的问题

由于Kettle的界面开发是基于swt包开发,所以对于不同平台要配置对应的开发包,如果在windows下,需要做如下操作

<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
查找上面的配置,全剧替换为
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>

具体有哪些包,参考如下仓库链接
https://repo.orl.eng.hitachivantara.com/ui/native/pnt-mvn/org/eclipse/swt/

3.2.2 修改ui/pom.xml配置,增加如下包,否则会报找不到class的错误
<dependency>
  <groupId>org.apache.xmlgraphics</groupId>
  <artifactId>xmlgraphics-commons</artifactId>
  <version>2.2</version>
</dependency>
<dependency>
  <groupId>jaxen</groupId>
  <artifactId>jaxen</artifactId>
  <version>2.0.0</version>
</dependency>

备注:由于系统中已经有xmlgraphics-commons:2.2,所以直接使用就可以,jaxen的版本,网上找个可用的就好

3.2.3 关于资源文件的拷贝

确保kettle-password-encoder-plugins.xml文件存在于core/src//main/resources目录下,如下图

确保ui/src/main/resources/ui下有如下资源文件

3.2.4 关于主配置文件spoon.xul的修改

Spoon.java为启动文件,在启动时会加载spoon.xul对系统进行初始化,在9.4.0.0-343版本中会报MenuItem版本错误,打开文件删除相关配置就可以,不影响正常使用

<menupopup id="new-file-popup">
    <menuitem label="${Spoon.Menubar.File.NewJob}" command="spoon.newJobFile()" image="images/chefgraph.svg"/>
    <menuitem id="menubar-new-trans" label="${Spoon.Menubar.File.NewTrans}" command="spoon.newTransFile()" image="images/spoongraph.svg"/>
    <menuseparator />
    <menuitem id="menubar-new-database" label="${Spoon.Menubar.File.NewDatabaseConn}" command="spoon.newConnection()" image="images/CNC.svg"/>
    <menuitem label="${Spoon.Menubar.File.NewSlave}" command="spoon.newSlaveServer()" image="images/slave.svg"/>
</menupopup>

4 备注

完成上面的修改,基本就能跑起来,经过测试

  • Windows上能跑起来,Jdk11,17都可以
  • Mac不能跑起来,启动时会报如下错误
org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.widgets.Display.error(Unknown Source)
    at org.eclipse.swt.widgets.Display.createDisplay(Unknown Source)
    at org.eclipse.swt.widgets.Display.create(Unknown Source)
    at org.eclipse.swt.graphics.Device.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
    at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:679)

Process finished with exit code 0

排查发现,估计是系统问题,因为swt会通过Jni调用原生库,如下

  • 引入的第三方版本问题

由于Kettle工程继承于pentaho-ce-jar-parent-pom工程,所以如果要修改第三方库版本号,则需要重新从顶级工程重新构建工程代码,顶级工程链接如下
https://github.com/pentaho/maven-parent-poms
在顶级工程里面定义了引入的第三库版本号

猜你喜欢

转载自blog.csdn.net/whg1016/article/details/129778155