Forum

maven-antrun-plugin...
 
Powiadomienia
Wyczyść wszystko

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

1 Wpisy
1 Użytkownicy
0 Reactions
1,000 Widoki
0
Rozpoczynający temat

example pom.xml

1 odpowiedź
0
Rozpoczynający temat

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

 

 

Twoja odpowiedź

Nazwa autora

E-mail autora

Twoje zapytanie *

 
Podgląd 0 rewizje Zapisano
Udostępnij: