You can change output of slots in sculptor-generator.properties:
Maybe we can introduce some new slot for documentation and according to this (http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) we can default it to src/site (src/generated/site?).
All *.btdesign is definitelly something we have to hide for packaging (src/main/scripts?). I don't like idea with META-INF, it's too deep for most important files.
You can change output of slots in sculptor-generator.properties:
By using this configuration (only known to the generator implementation internally) the Sculptor Maven plugin doesn't know the changed output locations.
There's no guarantee that the clean-up and image generation are working properly. This mechanism was intended for unit-/integration-testing of the generator.
In the context of a Maven build the corresponding Sculptor Maven plugin properties should be used instead.
Maybe we can introduce some new slot for documentation and according to this (http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) we can default it to src/site (src/generated/site?).
Yes, this makes sense.
All *.btdesign is definitelly something we have to hide for packaging (src/main/scripts?). I don't like idea with META-INF, it's too deep for most important files.Putting it in a separate resource folder of the Maven project will not hide the corresponding Sculptor meta data with the target build artifact. Without a name space (within the various resource folders) the Sculptor artifacts will be packaged in the root (JAR plugin) or "WEB-INF/classes/" (WAR plugin) of the final build artifact.
I'm only aware of a single use case where Sculptor meta data is need in a build artifact: In the case of a Sculptor model which is spread accross in multiple JARs at least the imported "*.btdesign" have to included somewhere in the client JARs.
So how about this:
- We place the Sculptor meta data in a separate folder (e.g. "src/main/sculptor/") which is not picked-up automatically by Mavens resource plugin.
- In Sculptors Maven plugin we put this folder on the generators classpath (these artifacts are only used by Sculptors generator internally).
- For packaging a Sculptor model client JAR (this is the only use case Sculptors meta data has to be available in a build target) Sculptor Maven plugin provides a new goal "package" (bound to Mavens package "phase") which puts folder as a resource (initialized with a sculptor-specific target path -> Java package, e.g. "META-INF/sculptor/") into the list of the projects resources. This way Mavens JAR plugin picks up Sculptors meta data and in places them in the aforementioned target path (Java package) configured in Sculptor Maven "package" goal.
In the context of a Maven build the corresponding Sculptor Maven plugin properties should be used instead.
Can't you simply load sculptor-generator.properties (and default-sculptor-generator.properties) they are for sure on classpath of plugin?
I will create new DOC slot and change doc templates to use it. Default will be 'src/site/generated'.
It looks good, however can't we just put src/main/sculptor to 'resources' in pom.xml? Normaly when you have 'shared' project you want build it always with model files packaged.
In the context of a Maven build the corresponding Sculptor Maven plugin properties should be used instead.Can't you simply load sculptor-generator.properties (and default-sculptor-generator.properties) they are for sure on classpath of plugin?I see your point (your hunting for KISS principle :-P). But there are times where simplicity is not sufficient :-)The Maven world it's not so simple:The Maven plugin itself doesn't use the Sculptor generator and its dependencies. The plugin only starts the generator as a black-box via the generators runtime main class. All the gory details of Sculptors generator with its Xtend magic, template overriding and overridden properties loader stuff is not available to the Maven plugin.So "loading sculptor-generator.properties" means copying stuff from the generator into the plugins pure-java/maven world. I don't think it's worth it.And I didn't start talking about architectural stuff like loose coupling, separation of concerns, abstracting technical details...I'm not keen on polluting the yet lean-'n-mean Maven plugin with too many generator-related internals. The current interface of setting a few system properties and calling a main method with some arguments seems appropriate to me.
I will create new DOC slot and change doc templates to use it. Default will be 'src/site/generated'.Great. Please use a ticket for this enhancement.
It looks good, however can't we just put src/main/sculptor to 'resources' in pom.xml? Normaly when you have 'shared' project you want build it always with model files packaged.You're going for the KISS principle again :-P) Ok, let's do a reality-check with the Maven world by using this resources-in-pom approach:
- The configuration of the POM becomes clumsy, because
- We've to repeat the default resource configuration because we're overriding the default resource configuration defined in the super POM.
- We've to define an include filter for "*.btdesign". The generator properties stuff has to be excluded from the client JAR to not being picked up the importing projects generator.
- Early in the life cycle (in "process-resources" phase) the Maven resource plugin picks up the filtered stuff in "src/main/sculptor" and copies it to "target/classes". So all the model stuff in the Sculptor folder is accessible by the other plugins.
- Later in the life cycle (in "package" phase) the jar plugin picks-up all the stuff from "target/classes/" (including our sculptor meta data). But wait: We only need this stuff for the client jar and not the main jar.
Hhm, it seems that in both approaches (your resources-in-pom approach and my additional-package-plugin-goal approach) we have to define filters for both executions of the JAR plugin (main and client jar).We should think about it :-)
I understand your point but adding something like:Property.load(This.class.getResourceAsStream("sculptor-generator.properties"))is not that much. You don't need any magic or generator internals. When is loaded than OK, override your defaults, it's about another 6 lines of code ;-). To make it more maven-ized, you can define property file name as another property.
Hhm, it seems that in both approaches (your resources-in-pom approach and my additional-package-plugin-goal approach) we have to define filters for both executions of the JAR plugin (main and client jar).We should think about it :-):-) I like your analytic approachMy idea was just put it inside pom in archetype into comment and than when needed just uncomment it.
I understand your point but adding something like:Property.load(This.class.getResourceAsStream("sculptor-generator.properties"))is not that much. You don't need any magic or generator internals. When is loaded than OK, override your defaults, it's about another 6 lines of code ;-). To make it more maven-ized, you can define property file name as another property.
Ok, in this case I would suggest to provide only a single place to let the user customize the output slots. Otherwise this leeds to confusion and unneccessary complexity. So let's remove the properties from the Maven plugin which are used to expose the output slots and use instead the generators code to retrieve the list of output slots used by the templates during code generation.
We could implement a new public static method "SculptorGeneratorRunner.getOutputSlots()" which use "PropertiesBase.getProperties("outputslot.path.", true)" internally. We have to do some classloader tricks to combine the Maven projects classpath (where the "sculptor-generator.properties" is located) with the generator libraries (where the "default-sculptor-generator.properties" is located). But should be doable.
At the end of the day the generator is reponsible to expose the list of output slots (which used internally by the templates) to the Maven plugin.
What do you think?
Hhm, it seems that in both approaches (your resources-in-pom approach and my additional-package-plugin-goal approach) we have to define filters for both executions of the JAR plugin (main and client jar).We should think about it :-):-) I like your analytic approachMy idea was just put it inside pom in archetype into comment and than when needed just uncomment it.
Ok, how about this:
By using the " additional-package-plugin-goal" approach with a name space (e.g. "META-INF/sculptor/") for the "*.btdesign" artifacts we can live with the fact that the (unfiltered) main jar and the client contain both the identical "*.btdesign" artifacts. If one doesn't like the sculptor models being packaged with the main jar can add a simple exclusion filter of "/META-INF/sculptor/*" to the JAR plugin execution config for the main jar.
I don't see a chance to get the Sculptor artifacts from being packaged to the main jar without using a filter. At the end of the day we need the artifacts in the client jar.
I'm not sure now, I will have to check but properties are lazy loaded after generation is started. You can't obtain values before generation but we can change this behavior.
Why you don't like idea of loading properties file directly, is here some classpath issue? Properties are defined on one place but read from two different places, that is not violation of anything.