Changing java service wrapper conf file property inside a pom - maven

I'm using java service wrapper in a project and want to change wrapper.logfile.maxsize
property of the wrapper.conf file.The thing is that it would be better if I can change it inside maven pom.xml file. So can anyone please tell me whether this is possible and if so how to do it ?
Thanx...

Use Maven Resource Plugin's Filtering feature. Let's say the line that needs to be configured by Maven looks like
wrapper.logfile.maxsize=500
Replace it with:
wrapper.logfile.maxsize=${wrapper.logfile.maxsize}
add filtering in the project/build/resources/resource/ section with:
<filtering>true</filtering>
and populate the right value from command line:
mvn resources:resources -Dwrapper.logfile.maxsize="500"

Related

maven 3.6.3 not able to execute `project.remotePluginRepositories`

I have been using maven 3.0.4 and one of our plugin's goal is using project.remotePluginRepositories. I have to now use maven 3.6.3 and I keep getting errors of value not found of project.remotePluginRepositories. The configuration of my goal is configured as:
<pluginRepos default-value="${project.remotePluginRepositories}"/>
I have also tried changing to the following, but I am still getting errors:
<pluginRepos>${project.remotePluginRepositories}</pluginRepos>
This pom.xml is in the child folder of the main folder with its pom.xml file.
I also can't find where project.remotePluginRepositories is defined so I also don't know how exactly the value is defined in XML format. Need help. Thanks

Maven execute plugin specified in pom

I am very new to Maven, and I am facing the situation that I need to execute plugin specified in pom.xml which generates java classes from xsd. This plugin is specified in build section so I need to compile all the code before it is triggered. Is there some way how to trigger the plugin with all its configuration specified in pom.xml directly?
I have searched online and the suggested way was to call
mvn org.apache.cxf:cxf-xjc-plugin:2.6.1:xsdtojava
(this is my plugin), but I am getting error Must specify xsdOptions, so from my understanding it is just calling the plugin without he config specified in pom.xml.
If someone could help me, it would be great. I can not edit the pom.xml!

Maven: how do I pass the artifactItems configuration to the dependency copy plugin from the command line?

I'd like the execute the Dependency Copy Plugin from the command line without the need to change the pom.xml file. I need to pass all configuration options from the command line. I can find some references to do it:
mvn -DuseRepositoryLayout=true dependency:copy
The problem is that I don't know how to set the <artifactItems><artifactItem> properties from the command line.
How would I invoke maven dependency copy plugin passing all necessary parameters in the command line?
You seem to mix two distinct goals :
copy-dependencies (referenced in your example) :
Goal that copies a list of artifacts from the repository to defined
locations.
copy (referenced in your link)
Goal that copies the project dependencies from the repository to a
defined location.
A user property in a mojo such as copy-dependencies provides a way to set a property from the command line with the -DMyUserProperty syntax.
From the copy plugin documentation you refer, you can read that the artifact property has as user property artifact.
So the example passing it from the command line is valid :
mvn dependency:copy -Dartifact=mygroupId:myartifactId:myversion
But the same plugin documentation doesn't specify any user property defined for the artifactItems property.
Besides, it is clearly stated :
Use artifactItems within the POM configuration.
So you are stuck to set artifactItems from a POM file.
As you don't want to bother with a POM and that you prefer to specify externally the dependencies to copy, dependency:copy-dependencies that provides a service enough close to which of copy-dependencies should better fit to your need as contrary to copy-dependencies, it provides a user property to include/exclude artifactIds/groupIds:
User Property: includeArtifactIds
...
User Property: includeGroupIds
You could so write something like :
mvn dependency:copy-dependencies -DincludeArtifactIds="myArtifactOne,
myArtifactTwo,..." -DincludeGroupIds="myGroupIdOne, myGroupIdTwo"

Setting System Properties for the maven-surefire-plugin via CLI

I am currently working on a use-case where I have to set a system property for the maven-surefire-plugin via command line. I've tried to use the systemPropertiesFile property but it seems like my build doesn't pick up the properties in the file . Here's the syntax that I've tried:
mvn install -DsystemPropertiesFile=<path-to-file>
I'm using Maven 3.0.5 for this. Setting the same property via the POM file works fine, but unfortunately that is not a solution I can use. Am I missing something?
systemPropertiesFile is not exposed as a user property, so if you don't want to change pom.xml you could use argLine:
mvn install -DargLine="-DmyProperty=abc -DotherPoperty=def"

setting maven properties by using shell command

I would like to obtain a value from a bash shell command and set a property using this value.
I am not sure setting the property is the way to go -- what I am trying to do is obtain a value from a shell command that is executed by Maven and to use this value to name the jar that is created.
More specifically, I would like to obtain using the git describe command the tag of a project and append this tag to the name of the jar.
I would like to do something like this within the pom:
tag = git describe
.
.
.
mv '$jarname'.jar '$jarname$tag'.jar
If I from the command line I execute
mvn jar:jar
I am not sure I can even affect the name of the resultant jar even if I had the git tag,
so that is another question.
I'm sure there are many other similar plugins out there, but you can use my exec-set-property plugin goal to set a Maven property using the output of a shell command.
What ended up working:
Goal was to be able to store SHA1 and git tag in the manifest of a jar.
Used the Maven plugin found here:
http://code54.com/blog/2012/04/30/buildversion-plugin.html
as well as the Maven buildnumber plugin.
These two plugins respectively set the Maven properties build-tag and buildNumber which
could then be specified in the Maven Jar plugin's manifestEntries section.

Resources