【Eclipse Maven Tycho】如何在生成的product中内置一份jre

前言

eclipse本身是基于java实现的,也就意味着eclipse ide必须要依托jre运行。作为开发者,通常会手动下载和配置jdk,然而作为非java开发者的用户而言,让其下载和配置jdk无疑会增加学习成本,影响用户体验。因此,将jre优雅的内置到eclipse ide中,是很有必要的。

此处借助eclipse的 justj 开源工程,来实现内置jre功能。本文以jre11为例

eclipse justj是一组开源的eclipse插件,其内置了各个版本、各个平台的jre

定义target platform

myide.target

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="mcstudio">
    <locations>
        <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
            <repository location="https://download.eclipse.org/releases/2021-12"/>
            <unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
        </location>
        <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
            <repository location="https://mirrors.tuna.tsinghua.edu.cn/eclipse/justj/jres/11/updates/release"/>
            <unit id="org.eclipse.justj.openjdk.hotspot.jre.minimal.feature.group" version="0.0.0"/> <!-- 包含justj jre -->
        </location>
    </locations>
</target>

定义product

myide.product
在.product文件中包含<feature id="org.eclipse.justj.openjdk.hotspot.jre.minimal" installMode="root"/>

pom.xml

在pom中配置target-platform-configuration插件,如下

<plugin>
	<groupId>org.eclipse.tycho</groupId>
	<artifactId>target-platform-configuration</artifactId>
	<version>${tycho-version}</version>
    <configuration>
        <executionEnvironment>org.eclipse.justj.openjdk.hotspot.jre.minimal-11</executionEnvironment> <!-- 这句很重要 -->
        <environments>
            <environment>
                <os>linux</os>
                <ws>gtk</ws>
                <arch>x86_64</arch>
            </environment>
        </environments>
        <target>
            <artifact>
                <groupId>com.zhangsan.myide</groupId>	<!-- .target文件所在的pom -->
                <artifactId>target</artifactId>
                <version>1.0.0-SNAPSHOT</version>
            </artifact>
        </target>
    </configuration>
</plugin>

构建完成后,生成的product中就内置了一份jre11


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值