maven: set property in/from plugin's pom.xml and access it in pom.xml which calls the plugin. how? - maven

i'm trying to set a property from a plugin it's pom.xml and access that property from the plugin-caller-pom.xml which calls that plugin. but the tries with different plugin like antrun (script::javascript) or properties-maven-plugin or maven-surefire-plugin were all not successfull.
have some one tried that before and can tell me the way, how to do this?
Thank you very much.
Regards

Related

Maven ignores plugin configuration from pom.xml

While executing a phase everything works as expected, when I try to call a plugin (mojo) directly like
mvn net.masterthought:maven-cucumber-reporting:5.5.0:generate
maven seems to ignore <configuration></configuration> block of the plugin specified in pom.xml. And if a parameter of the plugin is required, maven obviously fails as it thinks it is not set (did you try to look at your pom.xml, dear maven?). Is this by designed or I misunderstand something?
I guess you have put the <configuration> into an <execution> block.
If this is the case, move it out of <executions>.

Execute Maven plugin with custom classpath entry

I would like to call a maven plugin with a custom entry on its classpath. This is usually possible by adding <dependencies> inside the <plugin> tag. The problem is, what I would like to add to the classpath is not a maven artifact, but some random folder in my project (the reasons for this are quite obscure, I need a resource file to be present of the classpath, but I must not copy it to the /target/classes due to IDE shenanigans).
Is there any way to specify truly arbitrary classpath entries for a maven plugin?

Load a properties inside a jar

Can I load a properties file inside a jar in a maven plugin execution?
I have a jar with a system-properties (among other things). I can download and expand it, but I wonder if I there is a way to configure a maven plugin (maven jetty plugin) to load these properties. I was thinking in the:
<configuration>
<systemPropertiesFile></systemPropertiesFile>
</configuration>
You'll probably have to use dependency:unpack first to write the properties to a temporary file, and then the properties-maven-plugin to read the properties from that file.

what is project.build.directory in ANT

In my project the maven-antrun-plugin is used and in a number of places a property named
project.build.directory
is referenced but i can't understand to what value this property is set. I tried to google and found couple of places where this was mentioned but could not find a formal note on, to what value this property is set.
Also, since I am using the maven-antrun-plugin, it would be nice if you tell me this property is set by Maven or Ant.
project.build.directory is a maven property available as is when your ant script is embedded in your pom.xml
If you call an external ant build file, this property will be available under maven.project.build.directory
By default the value of this property is the target directory.
This default value can be changed by adding a <directory> element in the <build> section of your pom.xml:
<build>
<directory>something</directory>
...
</build>
More about maven properties in maven-antrun-plugin here
Specific quotes from this source:
All of the properties available to maven are also available in the target configuration. However, you may want to call an external Ant build script using the ant task. To avoid name conflicts, only a subset of the properties are passed to the external Ant build. These include all properties defined in the properties section of the POM. It also includes prefixed versions of some of the commonly used Maven properties.

Add test jars in maven-jetty-plugin or create test-war with maven-war-plugin

I'm using maven to build a multi-module webapp. I would like to run my integration tests in their own module and use the jetty plugin. In order to get everything to work I will need to add a couple of jars to the classpath for the war but I see no option for such a thing in the documentation http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#deploy-war-running-pre-assembled-war
I am able to deploy the war but it fails because it's missing the two jars I need to add.
Is there a way for me to add a couple extra jars to the plugin configuration?
If not, is there a way for me to package a "test-war" like you can do with test-jar in maven?
There are multiple ways to extend the web application classpath with the jetty-maven-plugin. The most appropriated for you would be to set the extraClasspath field in the webAppConfig block of your plugin configuration:
<configuration>
...
<webAppConfig>
...
<extraClasspath>path/to/your/custom-dependency.jar</extraClasspath>
</webAppConfig>
</configuration>
The documentation is not very consistent about that. But the javadoc is quite clear.
You can find relevant configuration examples on my jetty plugin wiki page.
Add the dependencies directly to the plugin's <dependencies/>. No need for scopes or anything -- they'll not enter your final artifact, but rather -- only be used by the Jetty plugin during execution.

Resources