Forum

maven-antrun-plugin...
 
Notifications
Clear all

maven-antrun-plugin: how to run java jar with arguments

1 Posty
1 Users
0 Reactions
806 Widok
0
Topic starter

example pom.xml

1 Answer
0
Topic starter

1. add dependency

    <dependencies>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>3.1.0</version>
            <type>maven-plugin</type>
        </dependency>
    </dependencies>

2. configure plugin

<plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <target name="copy files into server">
                                <copy file="./target/MY_FILE.jar" todir="${server.plugin.directory}"/>
                                <exec executable="C:\Program Files\Java\jdk-17.0.2\bin\java.exe" dir="MY_WORKING_DIR">
                                    <arg value="-agentlib:jdwp=transport=dt_socket,server=n,address=pc1:5005,suspend=y"></arg>
                                    <arg line="-jar C:\MY_WORKING_DIR\paper-1.19-81.jar"></arg>
                                    <arg value="-nogui"></arg>
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

3. create/start build configuration (when you click stop, app will stop eather)

4. agentlib:jdwp argument is for debbuger, start, set brekpoint and you're done :)

RUN & DEBUG

  1. create maven configuration
  2. set maven commands, example "clean package" (important for stages), set working directory 
  3. create Remote JVM Debug with Listen to remove JVM
  4. FIRST START DEBUGGER (listener)
  5. then start Maven/project

 

 

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: