properties-maven-plugin not working for goal write-project-properties - java

I need to export property values from mvn command line to a file which is needed for my java code later. But i always get the error:
[ERROR] Failed to execute goal
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties
(default-cli) on project MyApplication: The parameters 'outputFile'
for goal
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties
are missing or invalid -> [Help 1] [ERROR]
Here is my project structure
MyApplication
|src/main/java
|src/main/resources
|src/test/java
|src/test/resources
|lib ////(no files here yet)
|pom.xml
And my pom.xml is:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>write-project-properties</goal>
</goals>
<configuration><outputFile>${basedir}/lib/build.properties</outputFile>
</configuration>
</execution>
</executions>
</plugin>
Note: I tried by manually creating empty file build.properties in lib folder and even same error. Tried with plugin version 1.0.0 too.

OK, after hours of trying different combinations, (moved <configuration> above/out of <executions>)in pom.xml, i see now lib/build.properties file created. But can someone explain this please?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<configuration>
<outputFile>${basedir}/lib/build.properties</outputFile>
</configuration>
<executions>
<execution>
<id>write-project-properties</id>
<goals>
<goal>write-project-properties</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>

Related

Skip default jar creation in maven causes error

Im using maven 3.8.3. Tryig to avoid the step of the default jar creation, using the answers I found in topics like:
remove jar created by default in maven
What is the best way to avoid maven-jar?
What I tried:
1.
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<id>default-jar</id>
<phase/>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
</executions>
</plugin>
I also checked the solution of <packaging>pom</packaging> instead of jar. but I'm not sure this is the use case.
More details: This is a non-empty module, containing resources and generated unversioned java sources.
Solutins #1-#3 caused me the following error:
The packaging for this project did not assign a file to the build artifact.
Please assist, Thanks in advance.

Finding files by pattern in Maven

I need to pre-process some of the resource files (*.xsl) in a Java Maven project.
I found the exec-maven-plugin which is able to execute shell commands and thought I can do it in 2 steps:
match a list of files and write it to a file
launch a Java program that pre-processes each file from the list
However I don't get any output from the find command I am trying to execute. The plugin configuration in POM looks like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>inline-xml-entities</id>
<phase>generate-resources</phase>
<configuration>
<executable>find</executable>
<useMavenLogger>true</useMavenLogger>
<outputFile>xsl-files.txt</outputFile>
<arguments>
<argument>./src/main/webapp/static/com/atomgraph/</argument>
<argument>-type</argument>
<argument>f</argument>
<argument>-name</argument>
<argument>'*.xsl'</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
I can see in the mvn clean install -X log that the command gets executed:
[DEBUG] Executing command line: [find, ./src/main/webapp/static/com/atomgraph/, -type, f, -name, '*.xsl']
The xsl-files.txt file gets created, but it's empty :/
If I go to the project basedir and execute find ./src/main/webapp/static/com/atomgraph/ -type f -name '*.xsl' manually, I get a list of .xsl files as expected:
./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/acl/imports/acl.xsl
./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/acl/layout.xsl
./src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl
...
What am I missing?
This seems to have worked:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>find-xsl-files</id>
<phase>generate-resources</phase>
<configuration>
<executable>find</executable>
<workingDirectory>src/main/webapp/static/com/atomgraph/</workingDirectory>
<outputFile>xsl-files.txt</outputFile>
<commandlineArgs>. -type f -name '*.xsl'</commandlineArgs>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>

Maven generated-sources/annotations

Hey guy's I'm posting this question having spent a good deal of time researching and not found a detailed answer. Currently I'm having an issue with generating sources from AWS Workflow. I'm using Maven apt-maven-plugin and aspectj-maven-plugin. These plugins both work for generating the client classes for the activities yet fail with the following error when running mvn clean package or mvn clean install against my workflow classes.
Error
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-
plugin:1.7:compile (default) on project (myproject): Execution default
of goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile failed:
basedir (myproject)\target\generated-sources\annotations does not exist
-> [Help 1]
Plugins
<groupId>org.codehaus.mojo</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0-alpha-5</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-flow-build-tools</artifactId>
</aspectLibrary>
</aspectLibraries>
<complianceLevel>1.7</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<sources>
<source>
<basedir>${basedir}/target/generated-sources/annotations</basedir>
</source>
<source>
<basedir>src/main/java</basedir>
<includes>
<include>**/*.java</include>
</includes>
</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
I'm not sure how to go about fixing this issue and any help would be great.
The error message is clear- mvn could not find /target/generated-sources/annotations, but in pom it is stated as the source for aspectj-maven-plugin.
Does your code intend to generate sources under /target/generated-sources/annotations? If yes, then there is issue with generation, you'll need to expose more of your pom for me to tell what went wrong. If no, why not remove this part and give it another shot.
<source>
<basedir>${basedir}/target/generated-sources/annotations</basedir>
</source>
ps: I'd rather put this as comment but I'm not able to :(

maven custom plugin not working after download from central repo

I've created custom plugin (http://search.maven.org/remotecontent?filepath=sk/lukasvasek/project-version-dategenerator-mvn/0.0.001/project-version-dategenerator-mvn-0.0.001.pom). When I install it locally (mvn install) i can use goal dateversionoverrider withou problem. Hovewer when I download this plugin from maven central repo I'm getting error:
[ERROR] Could not find goal 'dateversionoverrider' in plugin sk.lukasvasek:project-version-dategenerator-mvn:0.0.001 among available goals
what am I missing?
Thanks in advance
ok so problem was in descriptor, so I changed it to code below and it works.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<goalPrefix>project-version-dategenerator</goalPrefix>
</configuration>
<executions>
<execution>
<id>default-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
<phase>process-classes</phase>
</execution>
<execution>
<id>help-descriptor</id>
<goals>
<goal>helpmojo</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>

Should the wsdlDirectory setting in maven have an effect?

Is the wsdlDirectory setting in maven supposed to have an effect? I am finding that the setting:
<wsdlDirectory>${basedir}/src/main/resources/wsdl/</wsdlDirectory>
has no effect.
Executing the command below
mvn -X clean:clean jaxws:wsimport
always results in the output below, unless the wsdl files are moved to /home/projects/amazon/fps/trunk/src/wsdl
[DEBUG] The wsdl Directory is /home/projects/amazon/fps/trunk/src/wsdl
[DEBUG] The binding Directory is
/home/projects/amazon/fps/trunk/src/jaxws
[DEBUG] The wsdl Directory
is /home/projects/amazon/fps/trunk/src/wsdl
[INFO] Nothing to do, no
WSDL found!
I am using 2.2.1 on my Debian build machine and Embedded maven 3.0.2 on my Windows 7 Eclipse environment.
My pom.xml is as follows (irrelevant bits removed):
<project xmlns="..." xmlns:xsi="..." xsi:schemaLocation="...">
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<id>AmazonFPSImport</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>
${basedir}/src/main/resources/wsdl/
</wsdlDirectory>
<wsdlFiles>
<wsdlFile>AmazonFPS.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>/wsdl/AmazonFPS.wsdl</wsdlLocation>
<sourceDestDir>
${basedir}/target/generated-sources/amazon/
</sourceDestDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Try moving the configuration section outside the <execution> tags. Or, bind to a specific phase
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>

Categories

Resources