Skip to content

Commit

Permalink
IconsDemo: Make it possible to execute from the root project/reactor
Browse files Browse the repository at this point in the history
    mvn package -DskipTests exec:java@demo
    mvn package -DskipTests exec:java@demo -Dexec.args=write_obj

See also:

-   Plugin Goal Invocation from Command Line
    <https://maven.apache.org/docs/3.3.1/release-notes.html#plugin-goal-invocation-from-command-line>
-   mojohaus/exec-maven-plugin#335
  • Loading branch information
stanio committed Nov 21, 2023
1 parent f53f411 commit d15d51b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>demo</id>
<configuration>
<skip>true</skip>
<!-- XXX: Required even with skipped executions -->
<mainClass>dummy</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
Expand Down
6 changes: 4 additions & 2 deletions xbrz-awt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<module.name>io.github.stanio.xbrz.awt</module.name>
<maven.install.skip>false</maven.install.skip>
<maven.deploy.skip>false</maven.deploy.skip>
<exec.mainClass>io.github.stanio.xbrz.awt.demo.IconsDemo</exec.mainClass>
</properties>

<dependencies>
Expand Down Expand Up @@ -46,12 +47,13 @@
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<id>demo</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>io.github.stanio.xbrz.awt.demo.IconsDemo</mainClass>
<skip>false</skip>
<mainClass>${exec.mainClass}</mainClass>
<classpathScope>test</classpathScope>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/9</additionalClasspathElement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
public class IconsDemo extends JFrame {

public IconsDemo() {
this("editbookmarks2");
}

public IconsDemo(String iconName) {
super("Icon Scaling");
super.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
super.getRootPane().getActionMap().put("exit", new AbstractAction() {
Expand All @@ -52,15 +56,14 @@ public IconsDemo() {
});
super.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), "exit");
initUI();
initUI(iconName);
}

private static Image loadImage(String name) {
return new ImageIcon(IconsDemo.class.getResource(name)).getImage();
}

private void initUI() {
final String imageName = "editbookmarks2";
private void initUI(String imageName) {
Image loresImage = loadImage(imageName + "-16.png");
Image hiresImage = loadImage(imageName + "-32.png");

Expand Down Expand Up @@ -192,13 +195,14 @@ private static BufferedImage scaleImage(Image image,
* @param args <i>unused</i>
*/
public static void main(String[] args) {
final String iconName = (args.length == 1) ? args[0] : "editbookmarks2";
SwingUtilities.invokeLater(() -> {
try {
javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
System.err.println(e);
}
IconsDemo frame = new IconsDemo();
IconsDemo frame = new IconsDemo(iconName);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d15d51b

Please sign in to comment.