Skip to content

Commit

Permalink
build: Add minimal Maven build
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Reichel <[email protected]>
  • Loading branch information
manticore-projects committed Mar 9, 2024
1 parent 5142a51 commit e7bc122
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ hs_err_pid*

# Ignore Gradle build output directory
build
target
out

.idea
/.project
/src/site/sphinx/changelog.rst
/src/site/sphinx/javadoc_snapshot.rst
/dependency-reduced-pom.xml
100 changes: 100 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<!-- Define the project's coordinates -->
<groupId>com.manticore-projects.tools</groupId>
<artifactId>H2MigrationTool</artifactId>
<version>1.4.0</version>

<!-- Define project properties -->
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<!-- Define the project's dependencies (if any) -->
<dependencies>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.6.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.222</version>
<scope>test</scope>
</dependency>
</dependencies>

<!-- Define the project's build configuration -->
<build>
<!-- Define the source and resource directories -->
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>

<!-- Define the plugins used in the build process -->
<plugins>
<!-- Define the Maven Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.manticore.h2.H2MigrationTool</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

</build>
</project>
26 changes: 21 additions & 5 deletions src/main/java/com/manticore/h2/H2MigrationUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.manticore.h2;

import com.manticore.h2.H2MigrationTool.ScriptResult;
import org.webswing.toolkit.api.WebswingUtil;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
Expand All @@ -27,6 +26,8 @@
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.sql.Connection;
import java.sql.Driver;
Expand All @@ -48,7 +49,6 @@
* @author Andreas Reichel <[email protected]>
*/
public class H2MigrationUI extends JFrame {

public static final ImageIcon LIST_ADD_ICON =
new ImageIcon(
ClassLoader.getSystemResource("com/manticore/icons/16/list-add.png"),
Expand Down Expand Up @@ -89,6 +89,22 @@ public class H2MigrationUI extends JFrame {
ClassLoader.getSystemResource("com/manticore/icons/64/dialog-question.png"),
"Dialog Question.");
private static final Logger LOGGER = Logger.getLogger(H2MigrationUI.class.getName());

private static boolean isWebSwing() {
try {
Class<?> clazz = H2MigrationUI.class.getClassLoader().loadClass("org.webswing.toolkit.api.WebswingUtil");
Method method =clazz.getMethod("isWebswing");
return (boolean) method.invoke(null);
} catch (ClassNotFoundException ex) {
LOGGER.log(Level.FINE, "Could not load the WebswingUtil", ex);
} catch (NoSuchMethodException |InvocationTargetException | IllegalAccessException ex) {
LOGGER.log(Level.FINE, "Failed to call the WebswingUtil.isWebswing() method", ex);
}
return false;
}

private final static boolean IS_WEBSWING = isWebSwing();

private static final Font MONOSPACED_FONT = new Font(Font.MONOSPACED, Font.PLAIN, 10);
private final DefaultListModel<File> databaseFileModel = new DefaultListModel<>();
private final JList<File> databaseFileList = new JList<>(databaseFileModel);
Expand Down Expand Up @@ -176,7 +192,7 @@ protected void process(List<Entry<File, String>> entries) {

if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (WebswingUtil.isWebswing()
if (IS_WEBSWING
&& desktop
.isSupported(Desktop.Action.OPEN)) {
try {
Expand Down Expand Up @@ -381,7 +397,7 @@ protected void process(List<Entry<File, String>> entries) {

if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (WebswingUtil.isWebswing()
if (IS_WEBSWING
&& desktop
.isSupported(Desktop.Action.OPEN)) {
try {
Expand Down Expand Up @@ -1148,7 +1164,7 @@ public void windowClosed(WindowEvent e) {
pack();
setMinimumSize(getSize());

if (WebswingUtil.isWebswing()) {
if (IS_WEBSWING) {
setExtendedState(MAXIMIZED_BOTH);
}

Expand Down

0 comments on commit e7bc122

Please sign in to comment.