For a plain Java/Swing application, I am currently migrating the ant buildscripts to a gradle build.
While I got it up and running quickly, changes in recompiled classes are no longer picked up while debugging in IntelliJ IDEA.
All my build/run actions are delegated to gradle.
Things I've considered:
/build/classes/
regardless of the used build toolsidea
plugin to my build.gradle, hoping it would fix any potential confusions of classpathsSo I put together this MVCE to illustrate my problem:
build.gradle:
group 'hotswaptest'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
src/main/java/HotSwappingOrNot.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class HotSwappingOrNot {
public static void main(String[] args) {
JFrame asdf = new JFrame();
asdf.setContentPane(new JLabel("asdf"));
asdf.setVisible(true);
asdf.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
float r = (float) Math.random();
Color c = new Color(r, 1-r, r);
asdf.setBackground(c);
}
});
}
}
In order to test hotswapping, I change the new Color(r, 1-r, r)
-bit to new Color(r, r, r)
and press Ctrl+Shift+F9
.
Not yet fixed IDEA-163187. I'm not aware of any workarounds available so far :(