Pregunta

I have a run configuration in my eclipse. In my project we have two branches : DEV and STABLE. I would like to create one run configuration for building my project whatever branch it is on.

For now, when I set Base directory with one of those two variables : ${project_path}, ${build_project}, I face this error :

Base directory doesn't exist or can't be read.

This works : ${workspace_loc:/my-project-dev-branch} but is tied to a particular branch. I must duplicate this configuration for building the stable branch.

  • So, how can I view the actual content of ${project_path}, ${build_project} ?
  • Or which variable should I use to get this result : ${workspace_loc:/${eclipse_variable_with_project_name}} ?
¿Fue útil?

Solución

I'm not sure I follow how your branches are represented within the workspace, but

  • ${project_path} represents a path relative to your workspace
  • ${build_project} will only be set during an actual build (not during an execution of your program)

Based on your description you want to be using ${project_loc} instead.

Nota: The project MUST be selected in the perspective project before launching the run configuration. Otherwise, you will get a message like in the screenshot below :

picture of Alert box popup with the text 'Launching MY RUN CONFIGURATION' has encountered a problem.  Variable references empty selection: ${project_loc}'

Otros consejos

As you are already creating a String Substitution variable, through Run Debug->String Substitution in Eclipse Preferences, to deal with separate paths, you could either:

  1. Create a variable, e.g. branch_loc, with a value of ${workspace_loc:/my-project-dev-branch}
  2. If the paths only differ slightly, e.g. by branch name, then you could create a variable branch with a value, e.g. dev, and then create branch_loc with ${workspace_loc}\${branch}

Then use ${branch_loc} for you Maven base directory.

It would be better to have all branches use the same path, which git and mercurial allow you to do. Then you could use ${project_loc} for your Maven base directory. For project_loc if you specify the project name of your project, e.g. ${project_loc:MY_PROJECT_NAME}, then it doesn't require you to select the project in order to work.

If you right click on the project and then select Properties, you can see what ${project_path} will resolve to by looking at path and what ${project_loc} will resolve to by looking at location.

First of all, if you are using git as version control system: Do not checkout the project twice, but just switch between branches in a single project. Git was designed for that and can do that in seconds. That way your problem would vanish completely.

If that is not an option, maybe putting the run configuration under version control itself would be an alternative. Set the Shared file option as shown with the first highlight: enter image description here

Then you can run the run configuration by selecting it in the respective project (as that is really a file there) and launch it via context menu. However, I've never tried this with the same launch configuration checked out twice.

You can set the base directory in below mentioned way:

${project_loc:${project_name}}

You can find the above variables from the variables option.

Also you can set your mvn command in goals as example below:

clean install -PautoInstallPackage -Padobe-public -DskipTests
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top