Error using exec-maven-plugin inside of iterator-maven-plugin - maven

We are currently using the exec-maven-plugin to import oracle .dmp files into a database. Our list of .dmp files keeps growing so I wanted to try using the iterator-maven-plugin to loop through a list of .dmp file names. when I wrap the iterator plugin around the exec plugin, I receive a java error about being unable to find 'executable' in class java.lang.Object. I'm not strong in Java but it looks like the iterator plugin is blocking the exec plugin from working correctly.
<build>
<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>iterator-maven-plugin</artifactId>
<version>0.5.1</version>
<executions>
<execution>
<id>import-dmp</id>
<phase>install</phase>
<goals>
<goal>iterator</goal>
</goals>
<configuration>
<items>
<item>file1.dmp</item>
<item>file2.dmp</item>
</items>
<pluginExecutors>
<pluginExecutor>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>exec-one</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>imp.exe</executable>
<commandlineArgs>${jdbc.user}/${jdbc.password}#${jdbc.db.name} FILE=${project.basedir}/export/target/database/#item# FULL=Y GRANTS=N INDEXES=N CONSTRAINTS=N IGNORE=Y</commandlineArgs>
</configuration>
</plugin>
</pluginExecutor>
</pluginExecutors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The error message I receive is
[ERROR] Failed to execute goal com.soebes.maven.plugins:iterator-maven-plugin:0.5.1:iterator (import-file) on project test-import: Unable to parse > configuration of mojo com.soebes.maven.plugins:iterator-maven-plugin:0.5.1:iterator for parameter executable: Cannot find 'executable' in class > java.lang.Object -> [Help 1]
[ERROR]
I've looked at the optional parameters for both the iterator plugin and the exec plugin to see if there is something I can add which would allow the exec plugin to work but nothing seems related to a java error.
Has anyone run into this error before?

Related

Creating an Archetype From POM: Property is Missing

I created a Maven archetype and want to create an example project of it in my repository, which seems to be an unusual use-case.
Since I don't want to create the archetype manually, I added the following execution:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<configuration>
<archetypeGroupId>my.company.archetypes</archetypeGroupId>
<archetypeVersion>${project.version}</archetypeVersion>
<groupId>org.acme</groupId>
<version>0.1.2-SNAPSHOT</version>
<interactiveMode>false</interactiveMode>
</configuration>
<executions>
<execution>
<id>archetype-one</id>
<goals>
<goal>generate</goal>
</goals>
<phase>package</phase>
<configuration>
<archetypeArtifactId>archetype-one</archetypeArtifactId>
<artifactId>one</artifactId>
<package>org.acme.one</package>
</configuration>
</execution>
</executions>
</plugin>
This leads to the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (archetype-one) on project examples: Archetype my.company.archetypes:archetype-one:0.9.0-SNAPSHOT is not configured
[ERROR] Property groupId is missing.
[ERROR] Property artifactId is missing.
[ERROR] Property package is missing.
Which is just not true, since I've defined all of these. At least the IDE proposes these tags on that position. Moving the configuration tags around doesn't help either.
So I checked the source code of generate, and lo and behold, the target GAVs aren't present.
How do I define them when generating an archetype directly from another pom.xml?
So I ended up using an entirely different Maven plug-in:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>archetype-one</id>
<goals>
<goal>exec</goal>
</goals>
<phase>package</phase>
<configuration>
<executable>mvn</executable>>
<arguments>
<argument>archetype:generate</argument>
<argument>-DarchetypeGroupId=my.company.archetypes</argument>
<argument>-DarchetypeVersion=${project.version}</argument>
<argument>-DgroupId=org.acme</argument>
<argument>-Dversion=0.1.2-SNAPSHOT</argument>
<argument>-DinteractiveMode=false</argument>
<argument>-DarchetypeArtifactId=archetype-one</argument>
<argument>-DartifactId=one</argument>
<argument>-Dpackage=org.acme.one</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
And since I wanted to generate multiple archetypes, I put the first six arguments into a general <configuration> block, and appended the remaining three with <arguments combine.children="append">.

No schemas have been found | XJC

Can someone please help me on this issue. I have more than 2 schema files in the same directory and trying to generate the java classes using xjc in maven.
Here is my pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb2.version}</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<clearOutputDir>false</clearOutputDir>
<extension>true</extension>
<schemaFiles>${root.dir}/schemas/PnTCacheSchema.xsd</schemaFiles>
<schemaDirectory>${root.dir}/schemas/</schemaDirectory>
<packageName>com.superpages.nbt.gen.pnt</packageName>
<outputDirectory>${root.dir}/nbt/src</outputDirectory>
</configuration>
</execution>
<execution>
<id>xjc1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<clearOutputDir>false</clearOutputDir>
<extension>true</extension>
<schemaFiles>${root.dir}/schemas/AdCacheSchema.xsd</schemaFiles>
<schemaDirectory>${root.dir}/schemas/</schemaDirectory>
<packageName>com.superpages.nbt.gen.cache</packageName>
<outputDirectory>${root.dir}/nbt/src</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Getting this exception
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (default-cli) on project gypsygen: No schemas have been found -> [Help 1]
Try enclosing <plugins> tag inside <pluginManagement> tag.

Override filename in maven when deploying file

I generate zip file in maven-assembly-plugin with specific name and want be able to deploy it.
I define $[my-version} property in initialize phase and I successfully get the file, but when deoplying I get the following error:
[ERROR]
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli)
on project my-project: C:\Users\pr\work\my-project\target\target\my-file-${my-version}.zip not found.
-> [Help 1]
Code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<file>target/my-file-${my-version}.zip</file>
<repositoryId>releases</repositoryId>
<url>${nexus.url}/content/repositories/releases</url>
</configuration>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<finalName>my-file-${my-version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/deployment.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
The problem was in order of phases. When calling goal "deploy:deploy-file" directly, the phase "intialization" wasn't processed.
So, one of the ways is to call it explicitly:
mvn initialize deploy-file

How to upload custom artifact after it was build using a windows bat command?

I have a windows batch file to create me a file myUser.aaa.
And I call this bat file using exec-maven-plugin
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>scripts/MyBat.bat</executable>
</configuration>
</plugin>
</plugins>
What I want to know is how can I install the file to my repo after the MyBat.bat was executed?
I first wanted to use an mvn command from the bat file to upload it but this job gets executed from a Jenkins server and it has its own maven config. If I run mvn from the bat file it will refer to the maven on the local system.
I would suggest to use the build-helper-maven-plugin to add the supplemental artifact to your build and afterwards it will be deployed in one go with the rest which can be done like this:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>some file</file>
<type>extension of your file </type>
<classifier>optional</classifier>
</artifact>
...
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
May be you should bind the exec-maven-plugin to an earlier phase or the build-helper-maven-plugin to a later phase. I would suggest to use prepare-package for the exec-maven-plugin. Furthermore i would suggest to use uptodate versions of the plugins.

How do i hook a batch file to maven?

i need to hook or attach a batch file to maven
so if lets say i type
mvn package
and the there were no errors then a batch file i created would start running.
is there a way of doing something like that ?
You can easily do that with the maven-exec-plugin and linking it with the package phase:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>runbatchfile</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>c:\path\to\file.bat</executable>
</configuration>
</plugin>
</plugins>
With this configuration : your batch file will be execute just after the default goal associated with the package phase.

Resources