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
Configuration of Code Generation through variables
April 24, 2018
13:29, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 144
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

Good morning,

the code generation facility of the new SDK is really great – a huge improvement over the previous style.

I created multiple config files to accommodate for selective generation of base and/or impl source code. This, unfortunately, leads to a duplication of most of the config file content. Is there any possibility to further parameterise the configuration files, similar to the possibility of the ${app.home} variable? Even environment variables would probably work, e.g. ${env[“myNamespaceUri”]}.

Setting variables thru command line parameters would be another possibility.

Regards,
Hans-Uwe

April 24, 2018
17:14, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi Hans-Uwe,

Thanks. Good idea, this is probably something we should improve in a future 3.x version.

Currently the models/ModelFolder and generates/generate/output tags are replaced. The current implementation will replace any java system property, in fact the app.home is added as system property by the launcher scripts. For adding your own, it is a bit complicated at the moment, but you could edit the scripts or set the JAVA_OPTS environment variable (see the scripts) for the process, e.g. on windows cmd before running the codegen.bat you could:

set JAVA_OPTS=-Dpropertyname=”value”

to set the ‘propertyname’ system property value as ‘value’.

If you are familiar with Maven, you could also try generating with the included maven plugin as then the configuration would be in the pom.xml and you could use maven property-replacement system for any parameter. The generate-once targets could be made to separate executions and toggled via maven profiles. If your project does not use maven, or you are not familiar with it, then this might be a bit overkill solution.

April 25, 2018
9:07, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 144
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

Hi Bjarne,

thanks for the explanations and tips. I’m using Gradle as a build system and call the command line script from there.
I will take a look at the codegen.sh script and will add additional commandline parameters, which I then translate into JAVA_OPTS=…

(Of course, it would be super nice to see some gradle support in future releases Cool)

Thanks for the response.

Hans-Uwe

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
15 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: 729

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala

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

Administrators: admin: 1