目录
背景介绍
看过网上很多介绍kettle插件开发的博文,在真正开发之前存在很多繁琐的工作,例如:将kettle工具中的lib包安装到本地maven仓库。通常会执行如下操作:
- 打开kettle/data-integration/lib目录,执行如下命令
mvn install:install-file -Dfile=./kettle-core-6.1.0.1-196.jar -DgroupId=org.pentaho.di -DartifactId=kettle-core -Dversion=6.1.0.1-196 -Dpackaging=jar
mvn install:install-file -Dfile=./kettle-dbdialog-6.1.0.1-196.jar -DgroupId=org.pentaho.di -DartifactId=kettle-dbdialog -Dversion=6.1.0.1-196 -Dpackaging=jar
mvn install:install-file -Dfile=./kettle-engine-6.1.0.1-196.jar -DgroupId=org.pentaho.di -DartifactId=kettle-engine -Dversion=6.1.0.1-196 -Dpackaging=jar
mvn install:install-file -Dfile=./kettle-ui-swt-6.1.0.1-196.jar -DgroupId=org.pentaho.di -DartifactId=kettle-ui-swt -Dversion=6.1.0.1-196 -Dpackaging=jar
mvn install:install-file -Dfile=./pentaho-metadata-6.1.0.1-196.jar -DgroupId=org.pentaho.di -DartifactId=pentaho-metadata -Dversion=6.1.0.1-196 -Dpackaging=jar
mvn install:install-file -Dfile=./metastore-6.1.0.1-196.jar -DgroupId=org.pentaho.di -DartifactId=metastore -Dversion=6.1.0.1-196 -Dpackaging=jar
- 1
- 2
- 3
- 4
- 5
- 6
- 打开kettle/data-integration/libswt/win64目录,执行如下命令
mvn install:install-file -Dfile=./swt-6.1.0.1-196.jar -DgroupId=org.pentaho.di -DartifactId=swt -Dversion=6.1.0.1-196 -Dpackaging=jar
- 1
执行这一堆命令,我们可能稍微能忍受一下(毕竟都是搬运工嘛,复制粘贴一下就好了)。然而,往往我们自己使用的又不是6.1.0.1-196这个版本,或者kettle升级了,或者本地仓库重置了,亦或接手这个项目的后来者(比如我),我们这个脚本还要手动替换一下。
为了实现插件开发流程的简化,结合已有的maven插件对pom文件进行了简单的修改,毕竟maven的天职就是对依赖包的统一管理嘛!!!
pom配置
在打开IDE之前,需要配置一下kettle的系统环境变量KETTLE_HOME,这个环境变量会在pom中使用。举个例子,在windows系统中,KETTLE_HOME可以配置为D:\Program Files\kettle71,该目录为kettle的安装目录,其文件结构如下:
.
└── kettle71
└── data-integration
├── classes
│ └── ...
├── lib
│ └── *.jar
├── libswt
│ ├── linux
│ │ ├── x86
│ │ │ └── swt.jar
│ │ └── x86_64
│ │ └── swt.jar
│ ├── osx64
│ │ └── swt.jar
│ ├── win32
│ │ └── swt.jar
│ └── win64
│ └── swt.jar
....
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
打开IDE或直接打开maven管理的kettle插件工程,修改pom.xml文件:
- properties标签配置
<properties>
<kettle.version>7.1.0.0-12</kettle.version>
<kettle.home.lib>${env.KETTLE_HOME}/data-integration/lib</kettle.home.lib>
<kettle.home.libswt>${env.KETTLE_HOME}/data-integration/libswt/win64</kettle.home.libswt>
</properties>
- 1
- 2
- 3
- 4
- 5
- plugin标签配置
添加maven-install-plugin插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>kettle-core</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>org.pentaho.di</groupId>
<artifactId>kettle-core</artifactId>
<version>${kettle.version}</version>
<packaging>jar</packaging>
<file>${kettle.home.lib}\kettle-core-${kettle.version}.jar</file>
</configuration>
</execution>
<execution>
<id>kettle-dbdialog</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>org.pentaho.di</groupId>
<artifactId>kettle-dbdialog</artifactId>
<version>${kettle.version}</version>
<packaging>jar</packaging>
<file>${kettle.home.lib}\kettle-dbdialog-${kettle.version}.jar</file>
</configuration>
</execution>
<execution>
<id>kettle-engine</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>org.pentaho.di</groupId>
<artifactId>kettle-engine</artifactId>
<version>${kettle.version}</version>
<packaging>jar</packaging>
<file>${kettle.home.lib}\kettle-engine-${kettle.version}.jar</file>
</configuration>
</execution>
<execution>
<id>kettle-ui-swt</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>org.pentaho.di</groupId>
<artifactId>kettle-ui-swt</artifactId>
<version>${kettle.version}</version>
<packaging>jar</packaging>
<file>${kettle.home.lib}\kettle-ui-swt-${kettle.version}.jar</file>
</configuration>
</execution>
<execution>
<id>pentaho-metadata</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>org.pentaho.di</groupId>
<artifactId>pentaho-metadata</artifactId>
<version>${kettle.version}</version>
<packaging>jar</packaging>
<file>${kettle.home.lib}\pentaho-metadata-${kettle.version}.jar</file>
</configuration>
</execution>
<execution>
<id>metastore</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>org.pentaho.di</groupId>
<artifactId>metastore</artifactId>
<version>${kettle.version}</version>
<packaging>jar</packaging>
<file>${kettle.home.lib}\metastore-${kettle.version}.jar</file>
</configuration>
</execution>
<execution>
<id>swt</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>org.pentaho.di</groupId>
<artifactId>swt</artifactId>
<version>${kettle.version}</version>
<packaging>jar</packaging>
<file>${kettle.home.libswt}\swt.jar</file>
</configuration>
</execution>
</executions>
</plugin>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
现在,只需要执行mvn validate命令即可将kettle依赖的jar包安装到本地的maven仓库。若更换kettle版本,只需更换properties标签中kettle.version的值即可。当然配置中还是存在依赖系统环境的缺陷,即${kettle.home.libswt},在windows64中使用win64,若换linux需要将win64改为liunx/x86_64,目前还没找到更好的解决办法,如果有谁知道欢迎告知!
参考资料
- kettle通用插件[kettlePlugins]使用说明
- Apache install:install-file
- Maven安装jar文件到本地仓库
- Maven中的几个重要概念(二):lifecycle, phase and goal
- Maven 生命周期
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-60ecaf1f42.css" rel="stylesheet">
<div class="more-toolbox">
<div class="left-toolbox">
<ul class="toolbox-list">
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#csdnc-thumbsup"></use>
</svg><span class="name">点赞</span>
<span class="count"></span>
</a></li>
<li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-Collection-G"></use>
</svg><span class="name">收藏</span></a></li>
<li class="tool-item tool-active is-share"><a href="javascript:;" data-report-click="{"mod":"1582594662_002"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-fenxiang"></use>
</svg>分享</a></li>
<!--打赏开始-->
<!--打赏结束-->
<li class="tool-item tool-more">
<a>
<svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
</a>
<ul class="more-box">
<li class="item"><a class="article-report">文章举报</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.csdn.net/formemorywithyou">
<img src="https://profile.csdnimg.cn/9/0/2/3_formemorywithyou" class="avatar_pic" username="formemorywithyou">
<img src="https://g.csdnimg.cn/static/user-reg-year/2x/8.png" class="user-years">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit"><a href="https://blog.csdn.net/formemorywithyou" data-report-click="{"mod":"popu_379"}" target="_blank">EricZeng05</a></span>
</div>
<div class="text"><span>发布了20 篇原创文章</span> · <span>获赞 15</span> · <span>访问量 8527</span></div>
</div>
<div class="right-message">
<a href="https://im.csdn.net/im/main.html?userName=formemorywithyou" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
</a>
<a class="btn btn-sm bt-button personal-watch" data-report-click="{"mod":"popu_379"}">关注</a>
</div>
</div>
</div>