Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Java 9 Platform Module System (JPMS) #164

Merged
merged 1 commit into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ jobs:
uses: gradle/gradle-build-action@v2
- name: Build
run: ./gradlew :build
- name: Assemble
run: ./gradlew :assemble
- name: Upload compiled Windows distribution
- name: jlinkZip
run: ./gradlew :jlinkZip
- name: Upload Windows jlink image
uses: actions/upload-artifact@v3
with:
name: listFix-windows
path: build/distributions/listFix-*.zip
path: build/image.zip
49 changes: 40 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ plugins {

// https://github.com/qoomon/gradle-git-versioning-plugin
id 'me.qoomon.git-versioning' version '6.4.2'

id 'org.beryx.jlink' version '2.26.0'
id 'org.gradlex.extra-java-module-info' version '1.3'
}

apply plugin: 'io.github.fvarrui.javapackager.plugin'
Expand Down Expand Up @@ -85,15 +88,11 @@ repositories {
dependencies {

// Provides christophedelory.playlist.*
implementation 'io.github.borewit:lizzy:2.0.0'
implementation 'io.github.borewit:lizzy:3.0.0'

// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'

// Apache SLF4J to Log4j2 Adapter (bridge)
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j2-impl
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0'

implementation 'jakarta.activation:jakarta.activation-api:2.1.1';

// Required for log4j yaml configuration files
Expand All @@ -106,10 +105,6 @@ dependencies {
// https://mvnrepository.com/artifact/commons-io/commons-io
implementation 'commons-io:commons-io:2.11.0'

// Used to read the version number from the manifest
// https://mvnrepository.com/artifact/com.jcabi/jcabi-manifests/1.2.1
implementation 'com.jcabi:jcabi-manifests:1.2.1'

// Provide JFontChooser
implementation 'com.rover12421.opensource:JFontChooser:1.0.5-3'

Expand All @@ -121,6 +116,7 @@ dependencies {
}

application {
mainModule = 'listFix.app'
// Define the main class for the application.
mainClass = project.mainClassName
}
Expand All @@ -131,6 +127,31 @@ jar {
}
}

// Convert legacy dependency to named Java module
extraJavaModuleInfo {
module('com.rover12421.opensource:JFontChooser', 'say.swing.JFontChooser') {
requires('java.desktop');
exports('say.swing')
}
module('org.objenesis:objenesis', 'org.objenesis') {
exports('org.objenesis')
}
module('org.mockito:mockito-core', 'org.mockito.core') {
exports('org.mockito.verification')
}
module('com.jcabi:jcabi-log', 'com.jcabi.log') {
exports('com.jcabi.log')
}
module('com.jcabi:jcabi-manifests', 'com.jcabi.manifests') {
//requires('com.jcabi.log')
exports('com.jcabi.manifests')
}
module('com.googlecode.plist:dd-plist', 'dd.plist') {
exports('com.dd.plist')
requires('java.xml')
}
}

def generatedDir = "$buildDir/generated"
def generatedSources = "$generatedDir/sources"
def generatedResources = "$generatedDir/resources"
Expand All @@ -150,6 +171,16 @@ sourceSets {
}
}

jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher{
name = 'listfix'
noConsole = false
jvmArgs = ['-Dlog4j.configurationFile=./log4j2.xml']
}
forceMerge 'jackson', 'log4j', 'log4j-core', 'slf4j', 'com.jcabi.log'
}

task fatJar(type: Jar) {
group = 'distribution'
manifest {
Expand Down
5 changes: 5 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

<module name="FileTabCharacter"/>

<!-- Ignore module-info.java -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>

<module name="TreeWalker">
<module name="RegexpSinglelineJava">
<property name="format" value="\s+$"/>
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/listfix/view/GUIScreen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package listfix.view;

import com.jcabi.manifests.Manifests;
import io.github.borewit.lizzy.playlist.PlaylistFormat;
import listfix.config.*;
import listfix.controller.ListFixController;
Expand Down Expand Up @@ -49,6 +48,8 @@
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.stream.Collectors;

public final class GUIScreen extends JFrame implements IListFixGui
Expand All @@ -58,15 +59,14 @@ public final class GUIScreen extends JFrame implements IListFixGui
private final FolderChooser _jMediaDirChooser = new FolderChooser();
private final List<Playlist> _openPlaylists = new ArrayList<>();
private final Image applicationIcon = this.getImageIcon("icon.png").getImage();
private final listfix.view.support.SplashScreen splashScreen = new listfix.view.support.SplashScreen("images/listfixSplashScreen.png");

private final listfix.view.support.SplashScreen splashScreen = new listfix.view.support.SplashScreen(this.getImageIcon("listfixSplashScreen.png"));
private ListFixController _listFixController = null;
private Playlist _currentPlaylist;
private IPlaylistModifiedListener _playlistListener;

private static final Logger _logger = LogManager.getLogger(GUIScreen.class);

private static final String applicationVersion = Manifests.read("Implementation-Version");
private static final String applicationVersion = getBuildNumber();

private static final int keyEventRenameFile = KeyEvent.VK_F2;

Expand All @@ -92,6 +92,20 @@ public GUIScreen()
postInitComponents();
}

public static String getBuildNumber() {
URL url = GUIScreen.class.getClassLoader().getResource("META-INF/MANIFEST.MF");
try
{
Manifest manifest = new Manifest(url.openStream());
Attributes mainAttributes = manifest.getMainAttributes();
return mainAttributes.getValue("Implementation-Version");
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}

/**
* Show the splash screen with initial text, load the media library & option files into memory, then prepare to init the UI
*/
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/listfix/view/support/SplashScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ public class SplashScreen extends JFrame
{
private final JLabel statusBar;

public SplashScreen(String imageResourcePath)
public SplashScreen(ImageIcon image)
{
ClassLoader cl = this.getClass().getClassLoader();
ImageIcon image = new ImageIcon(cl.getResource(imageResourcePath));

getContentPane().setLayout(new BorderLayout());
getContentPane().add(new JLabel(image));

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module listFix.app {
requires com.fasterxml.jackson.databind;
requires org.apache.logging.log4j;
requires java.desktop;
requires io.github.borewit.lizzy;
requires org.apache.commons.io;
requires say.swing.JFontChooser;

opens listfix.json;

uses io.github.borewit.lizzy.playlist.SpecificPlaylistProvider;
uses org.apache.logging.log4j.spi.Provider;
}