Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
CodeGen Omit the generation date
December 21, 2022
19:00, EET
Avatar
APesce
Italy
Member
Members
Forum Posts: 12
Member Since:
December 21, 2022
sp_UserOfflineSmall Offline

Hello,
the codegen generates my files correctly but at each launch the creation date changes.
On Git I find all the files in modification even if there is nothing special.
Is there a parameter to not generate the date?

/**
* Generated on 2022-12-21 17:40:53
*/

Regards.

December 22, 2022
11:41, EET
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 349
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

At the moment, CodeGen does not have support for omitting the generation date. This could be implemented in a future version.

If you’re working on a Maven project, you could consider using the CodeGen Maven plugin. This would allow you to generate the classes as part of the project’s build process and you wouldn’t need to include the generated classes in your Git repository. See CodeGen’s manual for more information on integrating it into a Maven project.

December 22, 2022
13:12, EET
Avatar
APesce
Italy
Member
Members
Forum Posts: 12
Member Since:
December 21, 2022
sp_UserOfflineSmall Offline

Hi Matt,
Thanks for the reply.
I prefer to versione files compiled by CodeGen to know if anything has changed.
Some time ago I had done the same thing also using Maven.

March 30, 2023
9:50, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Sorry for the confusion, but seems this was already done at some point, but not documented (other than a small mention of https://downloads.prosysopc.com/opcua/Prosys_OPC_UA_SDK_for_Java_4_Release_Notes.html#version-4-3-0).

In the configuration (maven or the standalone) do


<generates>
<generate>

<timestampOutputs>false</timestampOutputs>
</generate>
</generates>

And then it shouldn’t output the javadoc at for the type (that basically only included the timestamp).

March 30, 2023
12:19, EEST
Avatar
APesce
Italy
Member
Members
Forum Posts: 12
Member Since:
December 21, 2022
sp_UserOfflineSmall Offline

Thanks Bjorn, it works perfectly.

I have another problem when syncing files to Git:
every time i run the CodeGen, the “___Ids.java” files have the methods in different order. Same thing for the list of interfaces in the “Ids.java” file.

Is it possible to always have them in the same order?
So I don’t see modified files on Git.

Thank you,
Andrew

March 30, 2023
13:08, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hmm good point, I think we have not that much checked them. I don’t think that is doable directly without us making a new release (and I cannot guarantee that it would be in the next one, but let’s see). We do currently use a lib called JavaPoet, so it depends does it have deterministic output, but I think at the moment the Codegen just has internally things in a Set etc. so the output might not be deterministic due to that.

However, maybe instead an alternative solution could be to run some sort of an auto-formatter externally after you have run the generator? For example: https://github.com/google/google-java-format. Though, as an idea maybe we could include something like that internally and just format the output regardless (maybe with a flag to control), but that is something to be investigated later. In general I would assume you to have something similar for non-generated code anyway (that formats them when you save the file), maybe you can just run that manually.

P.S.
One option also, depending how much you like is to have a separate part that generates the model, produces an artifact that is included to the real project as source code dependency (e.g. in maven dependency plugin to unpack and include it as extra sources via the build helper plugin). Though, you would need to exclude any files you wish to modify manually. Technically method implementations can also be plugged from the outside, so the only thing requiring manual modifications is if you wish to store some state in the XXXTypeNode(s).

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
12 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 726

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_gallery

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1