@@ -65,6 +65,9 @@ public class JoobyMojo extends AbstractMojo {
6565 @ Parameter (property = "jooby.excludes" )
6666 private List <String > excludes ;
6767
68+ @ Parameter (property = "application.debug" , defaultValue = "true" )
69+ private String debug ;
70+
6871 @ Parameter (defaultValue = "${plugin.artifacts}" )
6972 private List <org .apache .maven .artifact .Artifact > pluginArtifacts ;
7073
@@ -84,8 +87,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
8487
8588 Set <String > classpath = new LinkedHashSet <String >();
8689
87- Optional < Artifact > hotreload = hotreload (pluginArtifacts );
88- classpath .add (hotreload . get (). getFile (). getAbsolutePath () );
90+ String hotreload = hotreload (pluginArtifacts ). get (). getFile (). getAbsolutePath ( );
91+ classpath .add (hotreload );
8992
9093 for (Artifact artifact : artifacts ) {
9194 String scope = artifact .getScope ();
@@ -101,7 +104,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
101104 cmds .addAll (0 , this .commands );
102105 }
103106 List <String > args = new ArrayList <String >();
104- args .addAll (vmArgs (vmArgs ));
107+ args .addAll (vmArgs (hotreload , vmArgs ));
105108 args .add ("-cp" );
106109 args .add (cp );
107110 args .add ("org.jooby.Hotswap" );
@@ -147,11 +150,27 @@ private String join(final List<String> includes) {
147150 return buff .toString ();
148151 }
149152
150- private List <String > vmArgs (final List <String > vmArgs ) {
153+ private List <String > vmArgs (final String agentpath , final List <String > vmArgs ) {
151154 List <String > results = new ArrayList <String >();
152155 if (vmArgs != null ) {
153156 results .addAll (vmArgs );
154157 }
158+ results .add ("-javaagent:" + agentpath );
159+ if (!"false" .equals (debug )) {
160+ // true, number, debug line
161+ if ("true" .equals (debug )) {
162+ // default debug
163+ results .add ("-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n" );
164+ } else {
165+ try {
166+ int port = Integer .parseInt (debug );
167+ results .add ("-agentlib:jdwp=transport=dt_socket,address=" + port + ",server=y,suspend=n" );
168+ } catch (NumberFormatException ex ) {
169+ // assume it is a debug line
170+ results .add (debug );
171+ }
172+ }
173+ }
155174 // logback
156175 File [] logbackFiles = {localFile ("config" , "logback-test.xml" ),
157176 localFile ("config" , "logback.xml" ) };
@@ -161,19 +180,20 @@ private List<String> vmArgs(final List<String> vmArgs) {
161180 break ;
162181 }
163182 }
164- // dcevm?
165- String altjvm = null ;
166- for (String boot : System .getProperty ("sun.boot.library.path" , "" ).split (File .pathSeparator )) {
167- File dcevm = new File (boot , "dcevm" );
168- if (dcevm .exists ()) {
169- altjvm = dcevm .getName ();
170- }
171- }
172- if (altjvm == null ) {
173- getLog ().warn ("dcevm not found, we recommend to install it: https://github.com/dcevm/dcevm" );
174- } else {
175- results .add ("-XXaltjvm=" + altjvm );
176- }
183+ // dcevm? OFF
184+ // String altjvm = null;
185+ // for (String boot : System.getProperty("sun.boot.library.path", "").split(File.pathSeparator))
186+ // {
187+ // File dcevm = new File(boot, "dcevm");
188+ // if (dcevm.exists()) {
189+ // altjvm = dcevm.getName();
190+ // }
191+ // }
192+ // if (altjvm == null) {
193+ // getLog().warn("dcevm not found, we recommend to install it: https://github.com/dcevm/dcevm");
194+ // } else {
195+ // results.add("-XXaltjvm=" + altjvm);
196+ // }
177197 return results ;
178198 }
179199
0 commit comments