如何远程调试maven构建?

时间:2017-12-20 14:49:21

标签: maven debugging raspberry-pi remote-debugging

我正在编写一个旨在使用Raspberry pi的Scala应用程序。我正在使用Pi4J库进行GPIO处理,因为我无法在我的开发机器上运行我的代码。

对于这个项目,我使用Maven和一些插件来帮助我进行部署(刚从here偷走)。它命令Maven通过ssh连接到我的Rpi,复制.jar并执行它。这是代码:

    <build>
        <!--This plugin will Transfer the executable JAR file to the Pi and runs it -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <phase>install</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <!-- ensure the target directory exists on the Raspberry Pi -->
                            <sshexec host="${pi.host}" port="${pi.port}" username="${pi.user}"
                                password="${pi.password}" trust="true" failonerror="false"
                                verbose="true" command="mkdir --parents ${pi.deployDirectory}" />

                            <!-- copy the JAR file to the Raspberry Pi -->
                            <scp
                                file="${project.build.directory}/${project.build.finalName}.jar"
                                todir="${pi.user}:${pi.password}@${pi.host}:${pi.deployDirectory}"
                                port="${pi.port}" trust="true" verbose="true" failonerror="true">
                            </scp>

                            <!-- run the JAR file on the Raspberry Pi -->
                            <sshexec host="${pi.host}" port="${pi.port}" username="${pi.user}"
                                password="${pi.password}" trust="true" failonerror="false"
                                verbose="true"
                                command="java -jar ${pi.deployDirectory}/${project.build.finalName}.jar" />
                        </tasks>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-jsch</artifactId>
                    <version>1.9.6</version>
                </dependency>
            </dependencies>
        </plugin>
    </build>

多亏了这一点,当我执行mvn install时,Maven在我的Rpi上部署并运行我的.jar文件。它工作正常时工作正常,但是当事情崩溃或无法按预期工作时我无法调试我的应用程序。如何在此设置中添加调试器,以允许我使用断点?

我尝试将参数添加到java -jar filename,例如java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y -jar filename,但是当它开始时我会得到答案Listening for transport dt_socket at address: 8000。当我运行mvnDebug install时,打印完全相同,但它甚至不想编译,它会立即将此消息抛给我。

0 个答案:

没有答案