Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Oomph » Update Resource for Checkstyle rule changes
Update Resource for Checkstyle rule changes [message #1777414] Wed, 29 November 2017 10:01 Go to next message
Yashu Liang is currently offline Yashu LiangFriend
Messages: 7
Registered: November 2017
Junior Member
I am new to oomph and what I am trying to do is:
1. I was able to install checkstyle plugin
2. I was able to create checkstyle configuration file using a "resource creation" task(stored in folder ${workspace.location|uri}/.metadata/.plugins/net.sf.eclipsecs.core/checkstyle-config.xml)
3. the project setup file(myProject.setup) contains steps decribed in step 1 and 2 is stored in a github repo and in eclipse.ini I have set the redirection -Doomph.redirection.index.redirection=index:/->https://github.com/myproject/master/setups/
4. everything works fine when I start the eclipse and the the checkstyle is installed and configured correctly
5. Now if I change in myProject.setup in the github repo the checkstyle rules(by modifying the "resource creation" task)
6. If I restart eclipse, there is no update notification, this means the new checkstyle rule is not applied.

How this can be done correctly, if you have any suggestion?

Regards, Yashu
Re: Update Resource for Checkstyle rule changes [message #1777559 is a reply to message #1777414] Thu, 30 November 2017 10:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
You've redirected the entire index to your own copy? That sounds less than ideal.... I wonder how that even works, i.e., how is it that https://github.com/myproject/master/setups/ serves up raw XML? Perhaps this isn't really working as you're expecting and the normal setup archive is loaded...

In any case, the resource creation task will only create a resource if it doesn't already exist. Only a resource modify task will always modify a resource to match the contents of the current definition. So probably you'd need both if you always wanted to modify the resource's current contents with the contents of your choice (or perhaps we should have a "force" option on the resource creation task).
Re: Update Resource for Checkstyle rule changes [message #1780094 is a reply to message #1777559] Wed, 17 January 2018 10:48 Go to previous messageGo to next message
Yashu Liang is currently offline Yashu LiangFriend
Messages: 7
Registered: November 2017
Junior Member
Thanks, but I only see "resource copy" and "resource creation" tasks. Is there a "resource modify" task?
Re: Update Resource for Checkstyle rule changes [message #1780098 is a reply to message #1780094] Wed, 17 January 2018 11:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
Sorry, it's called a Text Modify task.
Re: Update Resource for Checkstyle rule changes [message #1780121 is a reply to message #1780098] Wed, 17 January 2018 15:46 Go to previous messageGo to next message
Yashu Liang is currently offline Yashu LiangFriend
Messages: 7
Registered: November 2017
Junior Member
Thanks again. If I have to text modify tasks, how the order of execution is determined?

I am asking this, because for checkstyle rules, it is possible that I make change today, and then tomorrow I make another change, and so on.
Re: Update Resource for Checkstyle rule changes [message #1780144 is a reply to message #1780121] Thu, 18 January 2018 05:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
Order of task execution is somewhat complex and involves things like org.eclipse.oomph.setup.SetupTask.getPriority() with values from org.eclipse.oomph.setup.SetupTask.PRIORITY_*. So higher priority task types perform before lower priority task types. But generally you'll see tasks (of the same priority) performed in the order in which they appear in the setup. The Text Modify task will perform whenever any of the modification patterns match.
Re: Update Resource for Checkstyle rule changes [message #1780146 is a reply to message #1780144] Thu, 18 January 2018 07:22 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6394
Registered: July 2009
Senior Member
In the advanced properties you can also specify predecessors and/or successors (which should have a unique ID then).

See also https://wiki.eclipse.org/Eclipse_Oomph_Authoring#Understanding_Setup_Tasks_and_Scopes .
Re: Update Resource for Checkstyle rule changes [message #1780177 is a reply to message #1780144] Thu, 18 January 2018 12:22 Go to previous messageGo to next message
Yashu Liang is currently offline Yashu LiangFriend
Messages: 7
Registered: November 2017
Junior Member
Ed Merks wrote on Thu, 18 January 2018 05:43
Order of task execution is somewhat complex and involves things like org.eclipse.oomph.setup.SetupTask.getPriority() with values from org.eclipse.oomph.setup.SetupTask.PRIORITY_*. So higher priority task types perform before lower priority task types. But generally you'll see tasks (of the same priority) performed in the order in which they appear in the setup. The Text Modify task will perform whenever any of the modification patterns match.


Thanks again for your answer.

My question is still unclear, do you have any where describes how to write the modification patterns? I have searched a lot, but I can't find any documentation on this.

In my case, I would like to replace the whole text content with another content, how should I write the modification pattern?

Thanks a lot!
Re: Update Resource for Checkstyle rule changes [message #1780194 is a reply to message #1780177] Thu, 18 January 2018 14:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
You can look for examples. Use Navigate -> Open Setup -> Parent Models -> Catalog Index Eclipse and then use Ctrl-F to search for "Text Modify". Each pattern must include one or more capture groups that are replaced by the corresponding substitution. So you could have the pattern (.*) with the substitution being the entire new file contents.
Re: Update Resource for Checkstyle rule changes [message #1780202 is a reply to message #1780194] Thu, 18 January 2018 15:15 Go to previous messageGo to next message
Yashu Liang is currently offline Yashu LiangFriend
Messages: 7
Registered: November 2017
Junior Member
Thanks for your reply.

I have a file called internal_config_1511778113952.xml and with only one line "123" as content.

And I have the below tasks configured:
 <setupTask
      xsi:type="setup:TextModifyTask"
      id="settoaaaa"
      excludedTriggers="BOOTSTRAP"
      successor="settobbbb"
      url="${workspace.location|uri}/.metadata/.plugins/net.sf.eclipsecs.core/internal_config_1511778113952.xml"
      encoding="UTF-8">
    <modification
        pattern="(.*)">
      <substitution>aaaa</substitution>
    </modification>
  </setupTask>

  <setupTask
      xsi:type="setup:TextModifyTask"
      id="settobbbb"
      excludedTriggers="BOOTSTRAP"
      predecessor="settoaaaa"
      url="${workspace.location|uri}/.metadata/.plugins/net.sf.eclipsecs.core/internal_config_1511778113952.xml"
      encoding="UTF-8">
    <modification
        pattern="(.*)">
      <substitution>bbbb</substitution>
    </modification>
  </setupTask>


I am expecting the file to be changed:
1. from 123 to aaaa because of the 1st task
2. then changed from aaaa to bbbb because of the 2nd task

But actually in the end, the file turned out to be 2 lines of "bbbbbbbb", like this:
bbbbbbbb
bbbbbbbb

Could you help me understanding this? Thanks again.

[Updated on: Thu, 18 January 2018 15:25]

Report message to a moderator

Re: Update Resource for Checkstyle rule changes [message #1780245 is a reply to message #1780202] Fri, 19 January 2018 06:22 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6394
Registered: July 2009
Senior Member
That's probably caused by the fact that the isNeeded() method is called on all tasks in a first step. Only then the perform() method is called on those tasks that are considered "needed". See also https://wiki.eclipse.org/Eclipse_Oomph_Authoring#Understanding_Setup_Tasks_and_Scopes .

You can try to add multiple modifications to a single TextModifyTask inistead.
Re: Update Resource for Checkstyle rule changes [message #1780496 is a reply to message #1780245] Tue, 23 January 2018 12:10 Go to previous messageGo to next message
Yashu Liang is currently offline Yashu LiangFriend
Messages: 7
Registered: November 2017
Junior Member
I tried again, still with the file internal_config_1511778113952.xml with only one line "123" as content.

<setupTask
      xsi:type="setup:TextModifyTask"
      id="settoaaaa"
      excludedTriggers="BOOTSTRAP"
      url="${workspace.location|uri}/.metadata/.plugins/net.sf.eclipsecs.core/internal_config_1511778113952.xml"
      encoding="UTF-8">
    <modification
        pattern="(.*)">
      <substitution>aaaa</substitution>
    </modification>
  </setupTask>

I am expecting that the file content be changed to "aaaa"

After running this task, the file turned out to be like this:
aaaaaaaa
aaaa

Is there anything that I did wrong? Thank you.

Regards, Yashu
Re: Update Resource for Checkstyle rule changes [message #1780514 is a reply to message #1780496] Tue, 23 January 2018 15:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
The patterns is compiled with java.util.regex.Pattern.compile(String) so to get .* to match multiple lines you'd have to use the "Special constructs (named-capturing and non-capturing)", see the Java doc, for turning "m" (multi-line on). When that's on ^ will match the start of the whole string rather than the start of each line, and $ will match the end, so probably (?m)(^.*$) will match the entire input string.
Re: Update Resource for Checkstyle rule changes [message #1780591 is a reply to message #1780514] Wed, 24 January 2018 08:52 Go to previous messageGo to next message
Yashu Liang is currently offline Yashu LiangFriend
Messages: 7
Registered: November 2017
Junior Member
Thanks a lot for your hint.

I finally managed to replace the whole file content with the below task with 2 modifications:
<setupTask
      xsi:type="setup:TextModifyTask"
      id="settoaaaa"
      excludedTriggers="BOOTSTRAP"
      url="${workspace.location|uri}/.metadata/.plugins/net.sf.eclipsecs.core/internal_config_1511778113952.xml"
      encoding="UTF-8">
    <modification
        pattern="(?s)^(.*)">
      <substitution>aaa</substitution>
    </modification>
    <modification
        pattern="(?s)^(.*)">
      <substitution>bbb</substitution>
    </modification>
  </setupTask>


My file content is created like this:
123
456
789

After running the task with 2 modification(the 1st modification changes the whole content to aaa, and the 2nd modification changes the content to bbb), the file looks in the end:
bbb

This is exactly what I wanted. Thanks a lot!
Re: Update Resource for Checkstyle rule changes [message #1780597 is a reply to message #1780591] Wed, 24 January 2018 11:19 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
Thanks for sharing your results!

Regular expressions are extremely powerful, but they are also very hard to author when you start to get fancy.
Previous Topic:Adding the WebSphere plugin to oomp setup
Next Topic:p2 bundle pools and caching
Goto Forum:
  


Current Time: Wed Sep 19 21:26:26 GMT 2018

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

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

Back to the top