Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Oomph » Variable value and default value(Where is the difference between the two documented)
Variable value and default value [message #1799169] Fri, 30 November 2018 21:45 Go to next message
Mario Jauvin is currently offline Mario JauvinFriend
Messages: 64
Registered: October 2015
Member
I am running Oomph in basic mode. I have a variable say mirror with a default value of dm and no value defined. If I start oomph in basic mode it asks me to switch to advanced mode or else it exits because mirror id undefined. If I start oomph with an environment variable mirror=m then it will work in basic mode and use m. If I set the value to dm and create the same environment variable it will not use it.

How can I use the default value when there is no environment variable defined and use the environment variable when it is defined? Or am I misunderstanding something? I even tried defining mirror with a default value of ${mirror.default} whose value is set to dm but that did not work.
Re: Variable value and default value [message #1799190 is a reply to message #1799169] Sat, 01 December 2018 08:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30457
Registered: July 2009
Senior Member
Sorry, simple mode does not (cannot) prompt for variables and does not do full variable evaluation, only evaluation of system/environment properties. If it detects unresolved variables it will want to switch to advanced mode (in the best case) where there is of course a general page for prompted variables.
Re: Variable value and default value [message #1799206 is a reply to message #1799190] Sun, 02 December 2018 00:21 Go to previous messageGo to next message
Mario Jauvin is currently offline Mario JauvinFriend
Messages: 64
Registered: October 2015
Member
Ed thanks for your reply. So you are confirming what I have observed. However, I still have a valid question:

How can I use the default value when there is no environment variable defined and use the environment variable when it is defined? Where is this documented?

And as an additional question: How is default value used in variable resolution? I presume that it does not work when in simple mode but does it work and how in advanced mode?

Re: Variable value and default value [message #1799212 is a reply to message #1799206] Sun, 02 December 2018 12:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30457
Registered: July 2009
Senior Member
You could use the following approach to conditionally define the default value of a variable:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:setup="http://www.eclipse.org/oomph/setup/1.0">
  <setup:EclipseIniTask
      option="-Da.b.c="
      value="${a.b.c}"
      vm="true"/>
  <setup:VariableTask
      name="a.b.c"
      defaultValue="foo"/>
  <setup:VariableTask
      filter="(a.b.c.default=*)"
      name="a.b.c"
      defaultValue="${a.b.c.default}"/>
</xmi:XMI>
This variable would still be prompted.

You could use the following very similar approach to define the value of a variable:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:setup="http://www.eclipse.org/oomph/setup/1.0">
  <setup:EclipseIniTask
      option="-Da.b.c="
      value="${a.b.c}"
      vm="true"/>
  <setup:VariableTask
      name="a.b.c"
      value="foo"/>
  <setup:VariableTask
      filter="(a.b.c.default=*)"
      name="a.b.c"
      value="${a.b.c.default}"/>
</xmi:XMI>
This variable would not be prompted and could be used in Simple mode.

Explaining how variable evaluation works is rather complicated. In the end, it's driven primarily by the actual use of the variables in the tasks. When used, the variable's value must be resolved, and to resolve, the actual definition of the variable is used, at which point the value of that variable is used, which could of course involve more variables needing to be resolved; if there is no such variable defined, the system properties or the environment variables are considered for the value. Defaults are used to initialize the UI field of any prompted variable (and if there are choices, the first choice acts like a default). But this only kicks in for Advanced mode and in that mode, the user can change the value to trigger re-evaluation. The user could even introduce new variable references in the field which could introduce yet another a variable that needs prompting, if it is not already defined.
Re: Variable value and default value [message #1799600 is a reply to message #1799212] Mon, 10 December 2018 21:26 Go to previous messageGo to next message
Mario Jauvin is currently offline Mario JauvinFriend
Messages: 64
Registered: October 2015
Member
Ed thanks for the reply. I understand that the purpose of the EclipseInitTask above in your two examples is to define the a.b.c variable in the eclipse that will be installed by this setup file. Am I correct? If I do not need it in Eclipse (I just want to use it in the installer) can I omit it? In the second example above, how would I set the value of the a.b.c variable while running the installer? I know it references the default value but I do not still understand how to set it? User.setup? environment variable?

Thanks
Re: Variable value and default value [message #1799613 is a reply to message #1799600] Tue, 11 December 2018 07:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30457
Registered: July 2009
Senior Member
The Eclipse Ini is just an example to actually use the variable's value in a task, otherwise there is no prompting at all (nor any way to look at the tasks on the confirmation page to see the impact of the variable's value/use).

Your original question was how to use the value of an environment variable as a default value, so of course with the second example, to set it while running the installer you set the environment variable (or the system property).

So what exactly are you asking now?
Re: Variable value and default value [message #1799631 is a reply to message #1799613] Tue, 11 December 2018 15:39 Go to previous messageGo to next message
Mario Jauvin is currently offline Mario JauvinFriend
Messages: 64
Registered: October 2015
Member
You answered my question. Other than an environment variable, can it be set another way, i.e. in some other variable task in another included setup file? How would it be done, would I set the value or the default value?
Re: Variable value and default value [message #1799706 is a reply to message #1799631] Wed, 12 December 2018 18:18 Go to previous messageGo to next message
Mario Jauvin is currently offline Mario JauvinFriend
Messages: 64
Registered: October 2015
Member
Ed, I tried the second example and if I define an environment variable a_b_c=bar and run your second example, the eclipse ini task shows up as:
Eclipse Ini -Da.b.c=foo

What am I missing?
Re: Variable value and default value [message #1799711 is a reply to message #1799706] Wed, 12 December 2018 18:47 Go to previous messageGo to next message
Mario Jauvin is currently offline Mario JauvinFriend
Messages: 64
Registered: October 2015
Member
I just noticed that if I add a a.b.c=zem variable in a restricted CompoundTask in my user.setup then the variable will be set to bar? What gives? Is it broken?
Re: Variable value and default value [message #1799729 is a reply to message #1799711] Thu, 13 December 2018 06:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30457
Registered: July 2009
Senior Member
Look carefully at the tasks themselves. In both examples there is a filter on the variable task that tests if a.b.c.default has a value. If it has a value, that task is enabled. In the first case, the task sets the default value of the variable to use a.b.c.default's value. In the second case, the variable task sets the value of the variable to use a.b.c.default's value. In neither case does it help to set to environment variable or a system property using the name a.b.c itself.

I really have no clue how a.b.c=zem could possibly induce the value "bar". There must be something omitted from your post that would make sense of such a thing.

In any case, all questions about what's in the user.setup seem kind of moot when you're asking about Simple mode because then I have to wonder how you are planning to put a variable task into the user.setup when only Advanced mode prompts for variables and saves the variables in the user.setup, installation.setup, or workspace.setup. It seems like a chicken-before-the-egg type of problem...

Re: Variable value and default value [message #1799798 is a reply to message #1799729] Thu, 13 December 2018 16:31 Go to previous messageGo to next message
Mario Jauvin is currently offline Mario JauvinFriend
Messages: 64
Registered: October 2015
Member
I would request the user to add something to their setup using a previous version of eclipse already installed so that it may effect their invocation of eclipse-installer. The other method I intend to use is to setup an environment variable in the script that they use to invoke the eclipse-installer.
Re: Variable value and default value [message #1799799 is a reply to message #1799798] Thu, 13 December 2018 16:35 Go to previous message
Mario Jauvin is currently offline Mario JauvinFriend
Messages: 64
Registered: October 2015
Member
I think I just understood a misconception I had. I thought that the construct a.b.c.default refered to the default value of variable a.b.c! I just understood that a.b.c.default is just another variable!
Previous Topic:Extract and recompose windows installer - Java not found
Next Topic:Installed Eclipse Still referring to eclipse.org URL
Goto Forum:
  


Current Time: Fri Sep 20 19:05:04 GMT 2019

Powered by FUDForum. Page generated in 0.02306 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top