SAP / abap-cleaner

ABAP cleaner applies 95+ cleanup rules to ABAP code at a single keystroke
Apache License 2.0
434 stars 48 forks source link

Setting default profile for team members #276

Open KaranIses opened 6 months ago

KaranIses commented 6 months ago

Hi,

I‘ve got a problem regarding own profiles. Hope you don’t mind a little background to make it clear.

We recently created a suitable profile in our team, which we want every developer to use during their development. For that purpose we want to set it as the default profile for everyone, so that they don’t have to manually set it with every new release of eclipse.

By default the path to synchronized Team profiles, is stored under C:\Users\user\AppData\Roaming\SAP\ABAP cleaner\user\settings\main.cfj. But this path can’t currently be set for everyone via the installation, so everyone has to manually set it. And since we work on virtual desktops, such local files are regularly cleared when we get a new session, so that at the start of every week, we have to set it again.

But abap-cleaner has no such option to set profiles at the start of eclipse, at least from what I’ve found. Is there a way which I didn’t see? Or is there a workaround?

Kind regards Dominic

jmgrassau commented 4 months ago

Hi Dominic,

hm, it's annoying, of course, to be forced to manually repeat such a setup every week. Unfortunately, as of now, I am not aware of a workaround that might help :-( Maybe there is a way to automatically generate main.cfj as part of setup of the virtual desktops? Actually, from my understanding of Windows folders, …\AppData\Roaming\… should be the correct place for this kind of file.

Kind regards, Jörg-Michael

KaranIses commented 4 months ago

Hi Jörg,

just yesterday, I've found a workaround that worked for us. I opened the Source code from the specific release in Eclipse and manually changed the variable workDir in Program.java located in com.sap.adt.abapcleaner -> src -> com.sap.adt.abapcleaner.programbase:

image

There i changed line 41, so that the Path of the Directory where ABAP Cleaner searches for profiles ist set to the Directory of our team profiles.

MicrosoftTeams-image

Then I exported it as a JAR-File and replaced it in the plugins folder of the Eclipse..

This is probably not the cleanest approach, as the initialize method, where this code is situated, uses the import variable overrideWorkDir and changes workDir to the given value. Perhaps the right method would be to change the given Directory from the perspective of the caller, but I couldn't figure out where it is done.

As for now, this solution seems to work for us and just requires a little bit of manual editing. Maybe this approach can be moved, so that you can control it via a setting in Eclipse?

Kind regards Dominic

jmgrassau commented 4 months ago

Hi Dominic,

yes, this sounds like it could work; however, I assume you would have to repeat the exercise for every new ABAP cleaner release.

The overrideWorkDir parameter is used for tests to be able to set up a (temporary) workdir. The only product code call is from FrmMain.initialize(), so modifying the actual parameter there would even be better.

Just to understand this – so the AppData\Roaming\ folder is regularly cleared from your virtual desktops, but the Eclipse plugins and settings aren't?

Kind regards, Jörg-Michael

KaranIses commented 4 months ago

Hi Jörg,

this workaround right now has to be repeated, you're right. But as we mostly only update ABAP Cleaner when we also install a new Eclipse version. We only need to change it about every three month, so it's not that big of a deal.

I've found the FrmMain-File and the method you mentioned. I will change the workaround and paste the path there. Thanks for looking it up.

As for the AppData\Roaming\ folder: Via configuration, only certain parts of the C-drive are cleared with a new VDI session. Which specific folders aren't is not to my knowledge. But in my tests I discovered, that team profiles folder, which are set in ABAP Cleaner are cleared. Eclipse plugins and settings seem to be unaffected.

Maybe i can ask the admins to change the configuration, so that ABAP Cleaner isn't affected by the clear, but as for now the workaround seems to do the trick.

Kind regards, Dominic