sculptor-maven-plugin

56 views
Skip to first unread message

Pavel Tavoda

unread,
Sep 11, 2013, 11:30:14 AM9/11/13
to fornax-...@googlegroups.com
Another problem. When I rebuild generator I usually restart generation in my project. However plugin is resolving that nothing changed and skip generation. However clean plugin at meantime removed some classes and generated sources because I run 'clean' phase (mvn clean install).
Is it possible to somehow enforce generation when 'clean' phase was run (without additional switches)?

Pavel

Torsten Juergeleit

unread,
Sep 11, 2013, 2:44:23 PM9/11/13
to fornax-...@googlegroups.com
However clean plugin at meantime removed some classes and generated sources because I run 'clean' phase (mvn clean install).

Yes, that's intended. The 'clean' goal of Sculptors Maven plugin is bound to the 'clean' phase. The 'clean' goal deletes all the (unmodified) stuff generated by the last generator run. So the plugin is doing only it's job :-P
 

Is it possible to somehow enforce generation when 'clean' phase was run (without additional switches)?

Nope, during 'clean' phase only the 'clean' goal of Sculptors Maven plugin is executed. The 'generate' goal of Sculptors Maven plugin is bound to the 'generate-sources' phase.


What are you trying to achieve? Don't fight against Mavens conventions. You will loose this battle. Or use Ant instead :-P

/Torsten

Torsten Juergeleit

unread,
Sep 11, 2013, 2:55:32 PM9/11/13
to fornax-...@googlegroups.com
Is it possible to somehow enforce generation when 'clean' phase was run (without additional switches)?

Nope, during 'clean' phase only the 'clean' goal of Sculptors Maven plugin is executed. The 'generate' goal of Sculptors Maven plugin is bound to the 'generate-sources' phase.

Ok, you can override the plugin 'generate' goals default binding of 'generate-sources' with 'clean' within the projects POM, e.g.

	<plugin>
<groupId>org.sculptor</groupId>
<artifactId>sculptor-maven-plugin</artifactId>
<executions>
<execution>
<id>cleanup</id>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>code-generation</id>
<phase>clean</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>

But in this case "mvn clean" will not do a cleanup anymore but generates code instead. Not sure if this is a good idea.

/Torsten

Pavel Tavoda

unread,
Sep 12, 2013, 6:38:50 AM9/12/13
to fornax-...@googlegroups.com
Can plugin 'listen' also for clean phase and remember it and than when code-generation phase come, it will be not resolving if something was changed but instead it will run generation. Feasible?

Torsten Juergeleit

unread,
Sep 12, 2013, 5:40:48 PM9/12/13
to fornax-...@googlegroups.com
Let me explain some details of the Sculptor Maven plugin first. The plugin consists of three independent Goals (aka Mojos):
  • Goal "clean" (CleanMojo which is bound to Mavens "clean" phase) deletes all the stuff generated by the last generator run. The corresponding information is retrieved from the hidden file ".sculptor-status". This file is deleted afterwards.
  • Goal "generate" (GeneratorMojo which is bound to Mavens "generate-sources" phase) runs Sculptors code generator. A list of generated files is stored in the hidden file ".sculptor-status".
  • Goal "generate-images" (GraphvizMojo which is bound to Mavens "generate-resources" phase) uses the Image generator "dot" from the GraphViz tool to generate PNG files for all dot-files generated by the last generator run. The corresponding information is retrieved from the hidden file ".sculptor-status".
Each of these Mojos is lean 'n mean and does a single job. The Mojos don't know of each other. They can be bound to any of Mavens lifecycle phases. The Mojos are stateless, the only state is maintained in the hidden file ".sculptor-status" which is part of a Maven project.

Sure, we could tweak these Mojos to do stuff like "listening" and behaving differently in certain situations. But this is not what a Mojo usually does. This would increase complexity and may confuse the average user.

I'm still wondering why the same procedure we're recommending in step 8 of part 3 of the Hello World Tutorial isn't usable in this situation.

/Torsten

Pavel Tavoda

unread,
Sep 13, 2013, 4:16:11 AM9/13/13
to fornax-...@googlegroups.com
When you run 'clean install' or 'clean generate-sources', but you don't change any of (pom.xml, *.btdesign, ...) your build will 100% crash.
Maybe GeneratorMojo can listen on 'clean' phase and remember, that check is not necessary or if file .sculptor-status is not available (mean clean was running) again skip check phase and generate.

Or another question, what is purpose to skip generation when nothing changed? When I ask from Maven, please generate (install, generate-sources, ...) than generate, this should be default behavior. Why are we skipping generation, that's 99% of cases why we run maven. Why to enforce with another switch? Maybe we can introduce switch 'please check changes' if somebody want but I don't know such case anyway.

/Pavel

Torsten Juergeleit

unread,
Sep 13, 2013, 9:06:07 AM9/13/13
to fornax-...@googlegroups.com
When you run 'clean install' or 'clean generate-sources', but you don't change any of (pom.xml, *.btdesign, ...) your build will 100% crash.

What do you mean by "crash"?
Running "mvn clean install" in a project with unmodified Sculptor model will delete the previously generated stuff, then re-generate the Sculptor stuff and finally compile all the java classes (generated and manually created) in the project. Here I can't see a reason for crashing the build. At least not the builds I'm working with :-P

You can try this with the Sculptor Examples and Tutorials. I'd to do this plenty during migration of the examples and the documentation :-)



Or another question, what is purpose to skip generation when nothing changed? When I ask from Maven, please generate (install, generate-sources, ...) than generate, this should be default behavior. Why are we skipping generation, that's 99% of cases why we run maven.

That's for performance reasons. If running "mvn install" (e.g. during CI build) on a fairly complex Maven reactor (maybe with multiple module using Sculptor code generation) then you're not interested in getting re-generating unmodified stuff. Therefore "expensive" Maven plugins detect if anything changed and only run the "expensive" stuff if neccessary, e.g. compiler plugin uses timestamp approach, Castor plugin uses a copy-approach, dependency:unpack uses a marker directory approach, ...

Why to enforce with another switch? Maybe we can introduce switch 'please check changes' if somebody want but I don't know such case anyway.

From my experience using Scuptor in a fairly complex project manually "forcing" a Sculptor generation is rarely used. Basically I'm only aware of a single use case: Someone changes the Scuptor special-cases stuff.
Only a few devs are modifying the Sculptor model files. In this case the Sculptor Maven plugin kicks in and re-generates the code. The other devs are only using or modifying the generated stuff. These guys are not interested re-generating the whole universe e.g. while running the unit tests of a complex Maven reactor via "mvn test".

Just my 2cents.
/Torsten

Pavel Tavoda

unread,
Sep 16, 2013, 3:38:15 AM9/16/13
to fornax-...@googlegroups.com
On Friday, September 13, 2013 3:06:07 PM UTC+2, Torsten Juergeleit wrote:
When you run 'clean install' or 'clean generate-sources', but you don't change any of (pom.xml, *.btdesign, ...) your build will 100% crash.

What do you mean by "crash"?
Running "mvn clean install" in a project with unmodified Sculptor model will delete the previously generated stuff, then re-generate the Sculptor stuff and finally compile all the java classes (generated and manually created) in the project. Here I can't see a reason for crashing the build. At least not the builds I'm working with :-P

You can try this with the Sculptor Examples and Tutorials. I'd to do this plenty during migration of the examples and the documentation :-)
No, run 'mvn clean install' and than again 'mvn clean install'. Second time you are running it because you maybe changed java source or generator or something else except model files. This will crash. Project will be cleaned up but not generated.
 

Or another question, what is purpose to skip generation when nothing changed? When I ask from Maven, please generate (install, generate-sources, ...) than generate, this should be default behavior. Why are we skipping generation, that's 99% of cases why we run maven.

That's for performance reasons. If running "mvn install" (e.g. during CI build) on a fairly complex Maven reactor (maybe with multiple module using Sculptor code generation) then you're not interested in getting re-generating unmodified stuff. Therefore "expensive" Maven plugins detect if anything changed and only run the "expensive" stuff if neccessary, e.g. compiler plugin uses timestamp approach, Castor plugin uses a copy-approach, dependency:unpack uses a marker directory approach, ...
When you run 'mvn install' than OK, don't generate but when you run 'mvn clean install' you have to. That is feature which I ask for.
 

Why to enforce with another switch? Maybe we can introduce switch 'please check changes' if somebody want but I don't know such case anyway.

From my experience using Scuptor in a fairly complex project manually "forcing" a Sculptor generation is rarely used. Basically I'm only aware of a single use case: Someone changes the Scuptor special-cases stuff.
Only a few devs are modifying the Sculptor model files. In this case the Sculptor Maven plugin kicks in and re-generates the code. The other devs are only using or modifying the generated stuff. These guys are not interested re-generating the whole universe e.g. while running the unit tests of a complex Maven reactor via "mvn test".

Same as above 'mvn test', 'mvn install' don't have to 'force' generation but 'mvn clean install' have to, otherwise it will crash.

/Pavel

Torsten Juergeleit

unread,
Sep 16, 2013, 6:32:14 AM9/16/13
to fornax-...@googlegroups.com
Maybe I'm dumb but I don't get this. In the projects I'm testing the Sculptor Maven plugin (mainly the Sculptor examples), executing "mvn clean install" results in the following:
  1. In the "clean" phase Sculptors goal "clean" checks if the file ".sculptor-status" exists. If yes tehn it deletes all the generated stuff mentioned in this file. Finally ".sculptor-status" is deleted as well.
  2. In the "generate-sources" phase Scultors goal "generate" checks if the file ".sculptor-status" exists. If it not exists (e.g. it was deleted in the previous "clean" phase) then Sculptors code generator is started. Otherwise it's timestamp is compared with the timestamp of certain other files (pom.xml, *.btdesign and generator properties). Only if ".sculptor-status" is older than any of these files then Sculptors code generator is started.
For getting this result in the projects POM Sculptors Maven plugin goal executions has to be configured properly, e.g.

<build>
  <plugins>
    <plugin>
      <groupId>org.sculptor</groupId>
      <artifactId>sculptor-maven-plugin</artifactId>
      <executions>
        <execution>
          <id>cleanup</id>
          <goals>
            <goal>clean</goal>
          </goals>
        </execution>
        <execution>
          <id>code-generation</id>
          <goals>
            <goal>generate</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

By using Mavens "-X" option or Sculptors Maven plugin configuration property "<verbose>true</verbose>" this behaviour can be watched with all the gory details.

/Torsten

Pavel Tavoda

unread,
Sep 16, 2013, 7:17:32 AM9/16/13
to fornax-...@googlegroups.com
For some unknown reason (I'm sure I copy it from forum, maybe some old post) I had no 'cleanup' section. Now it is working as expected.
Sorry for disturbance.

/Pavel

Torsten Juergeleit

unread,
Sep 16, 2013, 8:05:27 AM9/16/13
to fornax-...@googlegroups.com
Great. I'm glad we got this fixed.
In this thread we can find stuff for the ticket #16 :-)

/Torsten
Reply all
Reply to author
Forward
0 new messages