Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Oomph » Modify config.ini
Modify config.ini [message #1744460] Tue, 27 September 2016 09:27 Go to next message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
In my own setup file I am looking for a way to add a configuration property to the config.ini file.

Is this possible and how can this be done?
Re: Modify config.ini [message #1744464 is a reply to message #1744460] Tue, 27 September 2016 10:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30993
Registered: July 2009
Senior Member
Jan, there's no specialized task for that but a Text Modify Task likely can do the trick. Here's an example from CDO Server:
<?xml version="1.0" encoding="UTF-8"?>
<setup:TextModifyTask
    xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:setup="http://www.eclipse.org/oomph/setup/1.0"
    url="${installation.location|uri}/${installation.relativeProductFolder}/configuration/config.ini"
    encoding="ISO-8859-1">
  <modification
      pattern="eclipse\.application=([^\r\n]*)">
    <substitution>org.eclipse.emf.cdo.server.app</substitution>
  </modification>
  <modification
      pattern="(osgi\.splashPath=)">
    <substitution>XXXosgi.splashPath=</substitution>
  </modification>
</setup:TextModifyTask>

Note that for each substitution there must be a corresponding capture-group in the pattern.
Re: Modify config.ini [message #1744480 is a reply to message #1744464] Tue, 27 September 2016 11:39 Go to previous messageGo to next message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
I thought so at first, but there is no pattern to match in the config.ini. All I want to do is add a line to config.ini, not modify an existing line.

The Text Modify Task does not help with that or does it?
Re: Modify config.ini [message #1744653 is a reply to message #1744480] Thu, 29 September 2016 10:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30993
Registered: July 2009
Senior Member
Regular expressions are very powerful, though hard to author. You want an expression that matches the whole input when it doesn't already contain what you want to add. Ideally you would insert the right line separator as well.

<?xml version="1.0" encoding="UTF-8"?>
<setup:TextModifyTask
    xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:setup="http://www.eclipse.org/oomph/setup/1.0"
    url="platform:/resource/emf/example.txt">
  <modification
      pattern="(?s)^((?!property=value).)*(\r?\n)$">
    <substitution>\1</substitution>
    <substitution>\2property=value\2</substitution>
  </modification>
</setup:TextModifyTask>

In this task, the input is matched if it doesn't already contain "property=value" and then the substitution replaces the first group with itself, and insert the line separator twice, with "property=value" inserted between the line separators. It only works if the file ends in a line separator...
Re: Modify config.ini [message #1744762 is a reply to message #1744653] Fri, 30 September 2016 05:50 Go to previous message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
Cool idea. Thanks.
Previous Topic:Refresh resource after copy resource task
Next Topic:Using multiple JRE in an installation
Goto Forum:
  


Current Time: Sun Mar 29 17:38:10 GMT 2020

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

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

Back to the top