I need to know how can I run Rmic. I have programmed my app in Java Eclipse and now I need to run Rmic. I tried it by running CMD, changing directory to Bin folder of my eclipse project and then typing command Rmic class name. It shows error unrecognised command. Is I am doing something wrong?
I use Maven and this is what I have in my pom file. It works quite well.
<groupId>org.codehaus.mojo</groupId>
<artifactId>rmic-maven-plugin</artifactId>
<executions>
<execution>
<id>rmi package</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<includes>
<include>**/*_Stub*</include>
</includes>
</configuration>
</execution>
<execution>
<id>rmi compilation</id>
<goals>
<goal>rmic</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
</configuration>
</execution>
Related
With maven I set up a plugin that runs an external script.
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>3.0.0</version>
<executions>
<execution>
<id>Execute External Command</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>
${basedir}/external.sh
</executable>
</configuration>
</execution>
</executions>
</plugin>
The problem is that it also starts with the mvn clean command. Is it possible not to start the plugin in clean phase? or is it possible to parameterize my external script with a parameter that makes me understand that I am in the clean phase?
Something like:
<executable>
${basedir}/external.sh ${phase}
</executable>
Can you try to change the phase in your plugin, for exmple:
<phase>install</phase>
full plugin:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>3.0.0</version>
<executions>
<execution>
<id>Execute External Command</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>
${basedir}/external.sh
</executable>
</configuration>
</execution>
</executions>
</plugin>
you can choose any of the other suitable phases.
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>
I am using download-maven-plugin to download some of resources to be used in my project. The download is successful and I can use the downloaded file.
However, what I want is to include the downloaded file in the JAR.
Note : The resource file will be included in the JAR when it was pre-downloaded before running the build, but if it is not present (e.g. deleted or I want to update it perhaps) the resource file is not included in the JAR.
Basically what I want is to include the recently downloaded file (from mvn clean install) in the output JAR.
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://downloadurl</url>
<outputFileName>error.json</outputFileName>
<outputDirectory>${project.resources.dir}/commons</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Same thing happens when I use maven-ant-run plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>download-files</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<get src="https://downloadurl"
dest="${project.resources.dir}/commons/data.json"
verbose="true"
usetimestamp="true"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Just download it to ${basedir}/target/classes before packaging phase. You don't need it to be in sources in order to include it to JAR.
Solved!
I changed the phase to process-resources..
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>download-files</id>
<phase>process-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<get src="https://downloadUrl"
dest="${project.resources.dir}/commons/error.json"
verbose="true"
usetimestamp="true"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
I have a maven module which is packaged as a zip with naming my-artifact-1.0-SNAPSHOT.zip using maven-shade-plugin.
Once the artifact has been installed into local maven repo, I need:
Copy zip to configured local folder.
Unzip archive.
Rename unzipped folder from my-artifact-1.0-SNAPSHOT to my-artifact.
This process should be cross-platform working on Windows, Linux, MacOS machines.
I read that it could be accomplished by using:
maven-dependency-plugin plus another plugin
maven-groovy-plugin
What would the best way to implement such a flow? Any examples are very appreciated.
No need for antrun in my opinion, the maven-dependency-plugin should do the trick:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>validate</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>[your.group.id]</groupId>
<artifactId>my-artifact-1.0-SNAPSHOT</artifactId>
<version>[your.version]</version>
<type>zip</type>
<outputDirectory>${project.basedir}/my-artifact/</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Regards,
Tom
You have a maven plugin that can execute Ant-Tasks. This tasks let you execute a lot of works. For example, to unzip a file:
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-resources</phase>
<configuration>
<tasks>
<unzip src="path/to/zip/file.zip" dest="path/to/unzip" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
You can check all availables task in the apache ant page (see references).
Reference:
https://ant.apache.org/manual/Tasks
I have a question concerning the maven javadoc plugin? I have configured that plugin with this values:
<build>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<noqualifier>all</noqualifier>
<reportOutputDirectory>${basedir}/MyDoc/javadoc</reportOutputDirectory>
<destDir>javadoc</destDir>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
</plugin>
...
</build>
Is there a way to create some kind of documentation, if I use the command mvn clean install? I donĀ“t want to create a Jar File with my JavaDoc documentation, I need a way to create the JavaDoc and put the created source file directly in my maven project.
Thanks !
Greetz
Marwief
To execute plugin during certain phase, add <phase> to <execution>. Plugin should be fired:
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase> <------ HERE
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
More on maven lifecycle here