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: 135
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: 982
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: 135
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: 518

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 708

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1465

Posts: 6252

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 982, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 319, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1