Hi Raphael, I have some archetypes. They are not generated during build, they are already there, made using the create-from-project originally and then updated and expanded by hand from time to time.
Sometimes we do some refactoring here and there in the code, and while all other artifacts gets compiled before being installed/deployed, and the compiler warns if something is wrong, the archetypes are only packaged, so no check is performed to see if the sample java classes (and other stuff in them) are still valid. Then, from time time, some users tell us "hey, I used the archetype to create a new project, but nothing is working", and we recall that we didn't updated the archetypes when we renamed that class, or that package, or that archetype, or whatever (we are still a lab, we still can change stuff pretty radically :D ) So, my idea is simply this, during the build, I could use the archetype to create a new project (in /tmp/ for example :D ), then try to build it, and see what the user see when they use our archetype. This way, at least the "is a project produced using this archetype still working?" question would be solved at every build. I already tried to do this invoking maven from inside the archetype pom, but I was thinking about using the maven embedder to run the archetype:create to generate the mock project, and then the "compile" or even the "test" goal to see if everything goes right. Afterall, I'm trying to determine if the final user of my archetype will be able to generate something functional out of it, or if I forgot something (a dependency, a refactoring, etc..). Moving it a step further, it would be nice if I could drive this from a junit test, making it simpler (we are all used to writing test, aren't we?) and giving me the flexibility to do whatever checks I want on the produced /tmp/ project. Basically I would make the lifecycle of the packaging archetype something like : - Generate the archetype - Generate e temp mock project using the archetype (run mvn archetype:create ) - Try to run mvn on the generated project (run at least mvn compile, but could even be mvn test or mvn install or anything the developer expects the user to do with the generated project) - Make sure the two steps above went ok :) - Then package it and install and deploy and everything Or, as an alternative : - Generate the archetype - Run junit tests - Give the developer a simple way to generate a temp mock project, see its content, run mvn on it, from the junit using the embedder or whatever else - Make sure junits went ok - Then package it and install and deploy and everything Or even both :) Simone Raphaël Piéroni wrote: > 2008/12/9 Simone Gianni <[EMAIL PROTECTED]>: > >> Hi all, >> in my Magma Apache Lab I'm building some Maven archetypes during the >> main build process, and everything is working fine. Anyway, from time to >> time, an archetype stops working properly due to a refactoring, like a >> class or package name change, or some other similar event. >> >> What I'd like to do is to test these archetypes during the build >> process. The first and easier test would be to actually use them to >> create a mock project and see it build properly, even eventually testing >> itself and propagating the failure to the main build process. >> > > Can you please explain me like toa child what you try to do. > during, your build, you have some sample projects that you turn into archetype > using the create-from-project goal, and would like to run these archetype > into new projects an then run some tests on theses new projects > in order to check that your archetypes are in sync with your libraries ? > > Raphaël > > > >> I found in this mailing list only one thread dealing with archetype >> testing, and it was invoking another mvn command, on a temporary >> directory i suppose. Also, they were suggesting to use the Shitty >> plugin, which actually builds some other projects to run integration tests. >> >> I think a possible solution could be to use the maven-embedder called >> from a Junit test. This would give all the flexibility to run even more >> than one build cycle (for example with different parameters) and/or to >> perform more checks after the project has been created or built. >> >> What I'd like to know from you all is : >> - have you found any other nice way of testing an archetype? >> - is there an interest in this or am I the only paranoid searching for >> such a solution? :D >> - would it make sense to you to make at least the "build-it test" the >> default test phase during archetype build? (I'm planning a contribution >> here :) ) >> >> Let me know what you think about it. >> >> Simone >> >> >> -- >> Simone Gianni CEO Semeru s.r.l. Apache Committer >> http://www.simonegianni.it/ >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> -- Simone Gianni CEO Semeru s.r.l. Apache Committer http://www.simonegianni.it/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
