How to reference packaged resources from the jasmine maven plugin? - maven

I want to use the jasmine-maven-plugin to test my maven my-webapp project. This project depends on another my-lib project that contains some required JavaScript libraries. When the my-webapp project is built, it adds the my-lib JAR to the WEB-INF/lib/ path of the generated WAR. Inside the my-lib JAR, the needed JS resources are in folders META-INF/resources and META-INF/test-resources.
How can I reference these packaged resources from the jasmine-maven-plugin goals jasmine:bdd and jasmine:test?
Note that I've also tried to run the goals in the integration-test phase like explained here, but I still can't reference the needed resources.
UPDATE: Would running jetty:run-war from within the jasmine-maven-plugin help? If so, how can I achieve that?

I think you would need to first use the maven-dependency-plugin to unpack the jar, under a different goal.
Something like this: unpack dependency and repack classes using maven?
Then you can specify the parameters, under the configuration section of the plugin for that goal, from wherever you unpacked the jar.
wherever/you/unpacked/
Run the unpack goal first, then the bdd and test.

Related

How to get all dependency jars for deployment

I am using one Apache open source project and its pre-built binary contains all the target jars and the corresponding dependency jars for deployment.
But when I build from source like mvn clean install, how could I also get the necessary dependency jars for deployment?
I suggest two options:
Build a fat jar: the maven output jar will contain ll necessary classes taken from its dependencies. To accomplish this task you can use the maven-assembly-plugin maven plugin. You can read a good tutorial here.
Configure maven to copy all needed jar in a specific folder. To accomplish this task you can use the maven-dependency-plugin maven plugin. You will find a good tutorial here.

Can I make a Maven plugin that generates a project and then builds that project?

Is it possible to combine the capabilities of an archetype and a normal Maven plugin into a single plugin?
I have a custom language which I can compile into Java source code. I've written a Maven plugin which does this in the generate-sources phase, adds the Java source to the project, and builds the project. It works as I'd expect.
However, to use it, I need to first write out a pom.xml file referencing my plugin and describing where the input files live. I'd like to be able to go straight from raw input files to compiled code in a single maven command.
For example, suppose I have this directory structure:
my-project/
some-input-file.dsl
I want to run
bash$ mvn com.waisbrot.plugin:generate -DgroupID=com.waisbrot package
and after Maven's done running have:
my-project/
some-input-file.dsl
pom.xml
target/
generated-sources/
plugin/
SomeInputFile.java
classes/
com/
waisbrot/
SomeInputFile.class
some-input-file-1.0.jar
Actually, the integration testing of the archetype allows you to declare the parameter and goals. So do this:
Pick the template project you want to create
mvn archetype:create-from-project. It will create a new archetype
Review src/test/resources/projects, especially goal.txt and archetype.properties (source: http://maven.apache.org/archetype/maven-archetype-plugin/integration-test-mojo.html). Tweak so install will be implicity
mvn verify will be able to build the archetype, run the it, and get it installed
Hope it helps

How to rebuild dependencies before running jetty from maven

I have a multi module maven project. One of the modules is a reusable part which is packaged into a jar, and the other is a war web-app which depends on the first module. When I use jetty:run-exploded on the second module, the packaged jar is taken from local maven repository whereas I want the first module to be rebuild and packaged into the resulting war. Is there any way to force such behavior instead of the default one?
From everything I can tell from reading documents about Maven's design and using Maven myself this cannot be done in the projects own directory.
Maven will not follow module paths UP a hierarchy. Using -amd (also make dependencies) will only work at the top level module that ties all the other multi-module pom's together. So what you can do is this:
At the TOP level directory
mvn -amd -pl jetty_module jetty:run-exploded
I think you can use maven Advanced Reactor Options to archive this.
http://www.sonatype.com/people/2009/10/maven-tips-and-tricks-advanced-reactor-options/
The -pl or –projects option allows you to select a list of projects from a multimodule project. This option can be useful if you are working on a specific set of projects, and you’d rather not wait through a full build of a multi-module project during a development cycle.
Maven -amd(also-make-dependents ) also help to build multi module project once. Using that you can build a project and any project that depends on that project.

Maven build - include classes in projects /src/main/webapp/WEB-INF/classes

We have to build ontop of an application that we did not develop and we need to include some classes from the Jar's WEB-INF directory. How do we get maven to do this? The eclipse deployment directory includes this for local deploy but the built war looks different and does not include the files we place in the source.
You can use the dependency plugin unpack dependency option to unpack from a dependency and output it to a location you desired.
http://maven.apache.org/plugins/maven-dependency-plugin/unpack-dependencies-mojo.html
Or alternatively, you can use the maven assembly plugin's unpack describtor to achieve the same thing.

Javadoc creation with maven

We have created a new artifact to generate javadoc. We have 40 artifacts defined as dependencies. Task is to create javadoc.jar and html pages for the 40 dependency artifacts.
Whats the best approach to achieve this in maven?
This is very unusual. Javadoc works on sources, not compiled classes, whereas maven dependencies reference classes, not sources.
So to make this work you'll have to do all of this:
since this is a dedicated javadoc artifact, it won't have a main JAR artifact, so you'll probably want to set the packaging to POM
make sure all your referenced artifacts have attached sources
add <classifier>sources</classifier> to all your dependencies
unpack all dependencies to a common root folder using dependency:unpack-dependencies
run javadoc on that folder
create a jar using the maven-assembly-plugin
attach that jar to the build using the buildhelper plugin
On re-reading the question: I'm assuming that you want to create combined docs of all dependencies. If not, you'll need 40 separate executions each of the javadoc, assembly and buildhelper plugins. Good luck with that.
A slightly more automated approach than the answer above:
So to make this work you'll have to do all of this:
since this is a dedicated javadoc artifact, it won't have a main JAR artifact, so you'll probably want to set the packaging to POM
make sure all your referenced artifacts have attached sources
add <classifier>sources</classifier> to all your dependencies
unpack all dependencies to a common root folder using dependency:unpack-dependencies
Change your sources directory to where you unpacked all the dependencies
Use the source plugin to manage all the Javadoc generation and deployment

Resources