1

I want to run a Java-Applet. I use a JBoss Server. I use Maven. I use Eclipse. I deploy my Web-Archive inside an Enterprise Archive onto the Server by using Eclipse.

For the Applet I need the Applet's .class-file in an accessible folder for the applet.html. My idea was to copy the .class-from the target-folder to the resources-folder of my Web-Archive. So I added following plugin to the pom.xml of the Web-Maven-Project:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.4</version>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
            <executions>
                <execution>
                    <id>copy-applet-related-classes</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>

                       <outputDirectory>${basedir}/target/LMS-Admin-Web-  0.0.1/resources/applet</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${basedir}/target/classes/de/test/lms/applet</directory>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

I think I'm messing up the phase and the goal. It worked once when I had the goal "install" for the package and executed "mvn clean install" inside my project-folder. The problem is when I use right-click->publish in Eclipse. I don't know, what goals are run than. I tried a lot around, but it doesn't apply in the JBoss' standalone/deployments/... file-system. Turns out this is also really hard to google. So I'd be thankful for any ideas, links or other help!

EDIT: I found out, that the classes-folder in the target-folder is edited when I publish, but the WEB-Folder which is packaged to the WAR-File isn't. Maybe I need a phase, which is before packaging? I'm to investigate further tomorrow.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
fancy
  • 2,077
  • 2
  • 23
  • 45
  • The phase was 'package'... I tried 'package' as a goal, because I thought you might have meant that, but it didn't help either. – fancy Jan 08 '13 at 20:56

2 Answers2

1

In my project I also needed an applet, which needed to be copied to the classes dir. Only difference is that I stored the applet as an artifact (thus in a jar). I'm using the process-resources phase for that. In your case probably too.

I'll add my solution in case you want to package your applet. Which you'll need to do, if you want to sign it.

            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.2</version>
                    <executions>
                        <execution>
                            <id>copy-signed-applet</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>copy</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>mygroupid</groupId>
                                        <artifactId>myapplet</artifactId>
                                        <version>${myapplet.version}</version>
                                        <outputDirectory>${project.build.outputDirectory}/path/to/applet</outputDirectory>
                                        <destFileName>myapplet.jar</destFileName>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>

If you are using Eclipse, you need to add plugin lifecycle-mapping (if you don't have it already) in your pluginManagement. Make sure that goal copy has action execute.

                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.apache.maven.plugins
                                        </groupId>
                                        <artifactId>
                                            maven-dependency-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.2,)
                                        </versionRange>
                                        <goals>
                                            <goal>copy</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute/>
                                    </action>
                                </pluginExecution>
...
Community
  • 1
  • 1
asgoth
  • 35,552
  • 12
  • 89
  • 98
  • I appreciate your answer and I'll probably use your approach. Still I'm really curious what would solve my problem, even if it might not by long-term relevant, because of the signing-process you mentioned ;) – fancy Jan 08 '13 at 21:19
  • I tried your approach. I had to put the into , because otherwise I had this error: "Plugin execution not covered by lifecycle configuration". Now that I have a new Applet-Maven-Project, I added it to the dependencies of my WAR-Project. This .jar is deployed (to the WEB-INF/lib folder). But a 'myapplet.jar' is nowhere to be found. Of course I replaced your placeholders in the -tag. Can I somehow see, what Eclipse does Maven-wise when I publish? – fancy Jan 10 '13 at 09:36
  • You need to execute the dependency-plugin in your lifecycle mapping. I'll add an example in the answer. – asgoth Jan 10 '13 at 10:06
  • I seem to be getting ahead, slowly. Now I have following Error: Error copying artifact from D:\Repos\LMS\LMS-Admin-Applet\target\classes to D:\Repos\LMS\LMS-Admin-Web\target\classes\applet\myApplet.jar (org.apache.maven.plugins:maven-dependency-plugin:2.2:copy:copy-signed-applet:process-resources) Google only suggests Bug-reports – fancy Jan 10 '13 at 13:05
  • Why are you copying from D:\Repos\LMS\LMS-Admin-Applet\target\classes? Normally it should copy from your local repo... (if you used the above code) – asgoth Jan 10 '13 at 13:07
  • What part would specify the copying from the filesystem and not the repository? Here is the complete build-part of my pom: http://pastebin.com/v5bfSkP4 – fancy Jan 10 '13 at 13:34
  • Do you build the applet.jar in the same pom? – asgoth Jan 10 '13 at 13:42
  • The Applet is a different Maven project. They are both as modules in a parent project. The Web-Project has the Applet-Project as a dependency. – fancy Jan 10 '13 at 13:51
0

You could try to use the Git Param Plugin : https://wiki.jenkins-ci.org/display/JENKINS/Git+Parameter+Plugin

It should help you.

Mat M
  • 1,786
  • 24
  • 30