简体   繁体   中英

Eclipse launch configuration: resolve active profiles in project

I have several .launch files for Eclipse (I'm using Eclipse Oxygen), here is an example

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
    <booleanAttribute key="M2_DEBUG_OUTPUT" value="false" />
    <stringAttribute key="M2_GOALS" value="clean com.google.cloud.tools:appengine-maven-plugin:deploy" />
    <booleanAttribute key="M2_NON_RECURSIVE" value="false" />
    <booleanAttribute key="M2_OFFLINE" value="false" />
    <stringAttribute key="M2_PROFILES" value="" />
    <listAttribute key="M2_PROPERTIES" />
    <stringAttribute key="M2_RUNTIME" value="EMBEDDED" />
    <booleanAttribute key="M2_SKIP_TESTS" value="true" />
    <intAttribute key="M2_THREADS" value="1" />
    <booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false" />
    <stringAttribute key="M2_USER_SETTINGS" value="" />
    <booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false" />
    <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc}" />
</launchConfiguration>

Note that I'm using ${project_loc} variable in order to make it usable for any project.

I'm using this kind of files because I can share those with my team. Also the most used Maven Build configurations are ready to go w/o configuring every time a new launch profile.

The problem I'm facing is related to the profile value

<stringAttribute key="M2_PROFILES" value="" />

With the CTRL+ALT+P shortcut on a project, I can select the proper profile to load ( Select Maven Profiles... function). I'm using different profile to discern the environment for the deploy (development, stage o production).

I'm trying to "inject" the profile I enabled for the project into the generic launch profile configuration, something like the ${project_loc} variable but related to the current Maven profile.

If this cannot be made I need to create a launch profile for each environment, which means 3 files per every goal to launch.

Is there a way to use/create an Eclipse variable that can be resolved with the Maven profile I activated on the project?

Something like

<stringAttribute key="M2_PROFILES" value="${maven.profile.id}" />

您需要创建一个Eclipse插件(或参与Eclipse m2e项目),以便使用专用扩展点定义变量。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM