Generating code with Walkmod

72 views
Skip to first unread message

koko...@gmail.com

unread,
Jul 15, 2014, 3:49:02 PM7/15/14
to wal...@googlegroups.com
Hello!
I'm trying to use Walkmod to generate AS3 classes from Java classes (POJO) and I have a couple of questions.

1. What is the simplest way to change an extension of output file?

2. If I set two templates in walkmod:commons:template trnsformation, will the second transformation handle the result of the first transformation? Or the original file?

One little suggestion: it would be easier to understand code if variables' names were longer.
For example ChainConfig ac = config.getChainConfig();
When I meet "ac" later, I do not rememer it's type and purpose. So I have to scroll up

koko...@gmail.com

unread,
Jul 15, 2014, 4:04:19 PM7/15/14
to wal...@googlegroups.com
Also I have an issue with running transformation.
I always get an exception with walkmod:commons:template transformation.

An exeception has been produced during the walkmod:commons:template transformati
on - org.walkmod.util.location.LocationImpl@141213a
        at org.walkmod.impl.DefaultChainWalkerInvocation.invoke(DefaultChainWalk
erInvocation.java:44)

With walkmod:commons:import-cleaner transformation it works.

I definetly have problem with path, but I do not know how to fix it.

walkmod

unread,
Jul 15, 2014, 4:07:34 PM7/15/14
to wal...@googlegroups.com
Hi,

Thank you for using walkmod! I answer your questions below:


El martes, 15 de julio de 2014 21:49:02 UTC+2, koko...@gmail.com escribió:
Hello!
I'm trying to use Walkmod to generate AS3 classes from Java classes (POJO) and I have a couple of questions.

1. What is the simplest way to change an extension of output file?

By default, the original files are overwritten, but you can change the output directory. If you would like to change completely the generated ouput (e.g a txt file) you need to create a plugin with your writer component. However, I wonder you are talking about the output of a template that does not correspond to a java code Isn't it?. If this is your usage scenario, you need to fix the "output" property of the template transformation with your custom name. Check the code at https://github.com/rpau/walkmod-core/blob/master/src/main/java/org/walkmod/templates/DefaultTemplateVisitor.java . For example:

  <transformation type="walkmod:commons:template" >
      <param name="templates" >
        [ "src/main/groovy/template1.groovy", 
          ...,
          "src/main/groovy/template2.groovy" ]
      </param >
      <param name="output" >myfile.txt</param >
  </transformation>

If you need more details, do not hesitate to contact us in this post :)

2. If I set two templates in walkmod:commons:template trnsformation, will the second transformation handle the result of the first transformation? Or the original file?


The first transformation
 
One little suggestion: it would be easier to understand code if variables' names were longer.
For example ChainConfig ac = config.getChainConfig();
When I meet "ac" later, I do not rememer it's type and purpose. So I have to scroll up
Ok, thank you :) We are working on support naming conventions and apply this kind of rules to ourselfs 

walkmod

unread,
Jul 15, 2014, 4:09:10 PM7/15/14
to wal...@googlegroups.com
Could you send us the complete stacktrace attaching a file?

Thanks

koko...@gmail.com

unread,
Jul 16, 2014, 1:24:31 AM7/16/14
to wal...@googlegroups.com
Thank you for the reply!

I have attached console output and example project.
Walkmod.xml is located at Walkmod-Example\Notebook-Client\walkmod.xml

вторник, 15 июля 2014 г., 23:09:10 UTC+3 пользователь walkmod написал:
console-output.txt
Walkmod-Example.zip

walkmod

unread,
Jul 16, 2014, 2:03:43 AM7/16/14
to
Hi,

One correction: if you have two templates inside the same transformation walkmod:commons:template, then the input of the second template is the original source file (or the output of the previous transformation), not the output of the first template. However, if you declare 2  walkmod:commons:template transformations in your xml in the same chain, the output of the first transformation (like any other) is the input of the second one.

Sorry, I had read the question too quickly. I will analyze your stacktrace as soon as possible :)

walkmod

unread,
Jul 21, 2014, 5:56:30 PM7/21/14
to wal...@googlegroups.com
Hi,

I have improved walkmod to solve your example. So, I have attached a library called walkmod-core-1.0.6.jar in the attached zip. This is a preliminary version of the next release. So, please, replace the walkmod-core library of your $WALKMOD_HOME/lib directory for this one before executing your example.

Then, with the added behavior, you can customize an specific suffix for the template output and one output is created per source file. The output produced has the same path than the original file but with a different suffix (by default ".result"). In your example, as you will see, I have specified a ".walkmod" suffix. 

BTW, we are on holidays until 15th August. So, probably, I will have some difficulties these days to ask your questions quickly.

Thank you for using Walkmod and do not hesitate to contact us for any further problem or doubt.


El miércoles, 16 de julio de 2014 08:03:43 UTC+2, walkmod escribió:
Hi,

One correction: if you have two templates inside the same transformation walkmod:commons:template, then the input of the second template is the original source file (or the output of the previous transformation), not the output of the first template. However, if you declare 2  walkmod:commons:template transformations in your xml in the same chain, the output of the first transformation (like any other) is the input of the second one.

Sorry, I had read the question too quickly. I will analyze your stacktrace as soon as possible :)

El miércoles, 16 de julio de 2014 07:24:31 UTC+2, koko...@gmail.com escribió:
Walkmod-Example-Solved.zip

walkmod

unread,
Aug 21, 2014, 12:17:53 PM8/21/14
to wal...@googlegroups.com
Hi,

I have uploaded the version with your changes! 

Thanks for your contribution :)
Reply all
Reply to author
Forward
0 new messages