Skip to content
Snippets Groups Projects
Unverified Commit a84cd9e3 authored by Andre Brait's avatar Andre Brait
Browse files

Upgrade Gradle wrapper, add Java 11 compatibility

parent 5f089216
No related branches found
No related tags found
No related merge requests found
1.0.0-beta5
\ No newline at end of file
1.0.0-beta6
\ No newline at end of file
......@@ -35,16 +35,13 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import io.franzbecker.gradle.lombok.task.DelombokTask
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'io.franzbecker.gradle-lombok' version '1.14'
id 'com.github.johnrengelman.shadow' version '4.0.2'
id 'io.freefair.lombok' version '3.6.6'
}
lombok {
version = "1.18.0"
sha256 = ""
version = "1.18.8"
}
version = rootProject.file('VERSION').text.trim()
......@@ -56,7 +53,13 @@ apply plugin: 'distribution'
apply plugin: 'idea'
apply plugin: 'eclipse'
sourceCompatibility = 1.8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
compileJava {
options.compilerArgs = ['--release', '8']
}
distTar.enabled = false
distZip.enabled = false
startScripts.enabled = false
......@@ -66,9 +69,8 @@ shadowDistTar.enabled = false
mainClassName = "sinalgo.Run"
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile
title = "Sinalgo API Documentation Version: ${version}"
failOnError = false
}
repositories {
......@@ -78,14 +80,10 @@ repositories {
dependencies {
compile group: 'org.jdom', name: 'jdom2', version: '2.0.6'
compile group: 'com.apple', name: 'AppleJavaExtensions', version: '1.4'
compile group: 'io.github.lukehutch', name: 'fast-classpath-scanner', version: '2.21'
compile group: 'io.github.classgraph', name: 'classgraph', version: '4.8.39'
//testCompile group: 'junit', name: 'junit', version: '4.12' // TODO enable tests
}
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
}
processResources {
with copySpec {
from 'VERSION'
......@@ -114,20 +112,6 @@ run {
}
}
// Delombok Task
task delombok(type: DelombokTask, dependsOn: compileJava) {
ext.outputDir = file("$buildDir/delombok")
outputs.dir(ext.outputDir)
sourceSets.main.java.srcDirs.each {
inputs.dir(it)
args(it, "-d", ext.outputDir)
}
}
// Javadoc Task
javadoc {
includes = ['**/*.java']
dependsOn delombok
source = delombok.outputDir
failOnError = false
delombok {
generateLombokConfig.enabled = false
}
\ No newline at end of file
#Wed Jun 12 21:11:21 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
......@@ -51,7 +51,6 @@ import sinalgo.gui.dialogs.GenerateNodesDialog;
import sinalgo.gui.dialogs.GlobalSettingsDialog;
import sinalgo.gui.dialogs.GraphInfoDialog;
import sinalgo.gui.dialogs.GraphPreferencesDialog;
import sinalgo.gui.dialogs.HelpDialog;
import sinalgo.gui.transformation.PositionTransformation;
import sinalgo.io.eps.Exporter;
import sinalgo.nodes.Position;
......@@ -63,10 +62,25 @@ import sinalgo.runtime.SinalgoRuntime;
import sinalgo.runtime.events.Event;
import sinalgo.tools.storage.SortableVector;
import javax.swing.*;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import java.awt.*;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsEnvironment;
import java.awt.KeyboardFocusManager;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
......@@ -74,9 +88,12 @@ import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Vector;
......@@ -861,7 +878,14 @@ public class GUI extends JFrame implements ActionListener {
} else if (e.getActionCommand().equals(this.getAboutMenuItem().getActionCommand())) {
new AboutDialog(this);
} else if (e.getActionCommand().equals(this.getHelpMenuItem().getActionCommand())) {
HelpDialog.showHelp(this); // start in a new thread
if(0 == JOptionPane.showConfirmDialog(this, "This will open Sinalgo's help page on the default browser. Do you want to continue?",
"Help", JOptionPane.YES_NO_OPTION)) {
try {
Desktop.getDesktop().browse(new URI(Configuration.SINALGO_WEB_PAGE));
} catch (IOException | URISyntaxException ignore) {
// Do nothing if this is somehow wrong
}
}
} else if (e.getActionCommand().equals(this.getExitMenuItem().getActionCommand())) {
Main.exitApplication();
} else if (e.getActionCommand().equals(this.getViewFullScreenMenuItem().getActionCommand())) {
......
/*
BSD 3-Clause License
Copyright (c) 2007-2013, Distributed Computing Group (DCG)
ETH Zurich
Switzerland
dcg.ethz.ch
2017-2018, André Brait
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package sinalgo.gui.dialogs;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.web.WebHistory;
import javafx.scene.web.WebView;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import sinalgo.configuration.AppConfig;
import sinalgo.configuration.Configuration;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
@Getter(AccessLevel.PRIVATE)
@Setter(AccessLevel.PRIVATE)
public class HelpDialog extends JFrame implements ActionListener, WindowListener {
private static final long serialVersionUID = 5648555963120786571L;
private JFXPanel fxPanel;
private HelpDialog(JFrame parent) { // is private, use showHelp() to create it in a new thread
super("Sinalgo Help (source: " + Configuration.SINALGO_WEB_PAGE + ")");
fxPanel = new JFXPanel();
Platform.runLater(() -> {
WebView wv = new WebView();
wv.getEngine().load(Configuration.SINALGO_WEB_PAGE);
wv.setContextMenuEnabled(false);
getFxPanel().setScene(new Scene(wv, 500, 500));
HelpDialog.this.setMinimumSize(new Dimension(500, 500));
HelpDialog.this.setIconImage(parent.getIconImage());
HelpDialog.this.add(new JScrollPane(fxPanel));
HelpDialog.this.addWindowListener(this);
HelpDialog.this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
HelpDialog.this.restoreWindowState();
wv.setOnKeyPressed(e -> {
if (!e.isConsumed()) {
if (e.getCode() == KeyCode.LEFT && e.isAltDown()) {
WebHistory h = wv.getEngine().getHistory();
if (h.getCurrentIndex() > 0) {
h.go(-1);
}
} else if (e.getCode() == KeyCode.RIGHT && e.isAltDown()) {
WebHistory h = wv.getEngine().getHistory();
if (h.getCurrentIndex() < h.getEntries().size() - 1) {
h.go(1);
}
}
}
});
HelpDialog.this.setVisible(true);
HelpDialog.this.pack();
});
// Detect ESCAPE button
KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
focusManager.addKeyEventPostProcessor(e -> {
if (!e.isConsumed() && e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ESCAPE) {
HelpDialog.this.dispose();
}
return false;
});
}
private void saveWindowState() {
AppConfig.getAppConfig().setHelpWindowHeight(this.getHeight());
AppConfig.getAppConfig().setHelpWindowWidth(this.getWidth());
AppConfig.getAppConfig().setHelpWindowPosX(this.getLocation().x);
AppConfig.getAppConfig().setHelpWindowPosY(this.getLocation().y);
AppConfig.getAppConfig().setHelpWindowIsMaximized((this.getExtendedState() == Frame.MAXIMIZED_BOTH));
AppConfig.getAppConfig().writeConfig();
}
private void restoreWindowState() {
this.setPreferredSize(new Dimension(AppConfig.getAppConfig().getHelpWindowWidth(),
AppConfig.getAppConfig().getHelpWindowHeight()));
this.setLocation(new Point(AppConfig.getAppConfig().getHelpWindowPosX(),
AppConfig.getAppConfig().getHelpWindowPosY()));
if (AppConfig.getAppConfig().isHelpWindowIsMaximized()) {
this.setExtendedState(Frame.MAXIMIZED_BOTH);
}
}
@Override
public void actionPerformed(ActionEvent e) {
}
@Override
public void windowClosed(WindowEvent e) {
this.saveWindowState();
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
this.saveWindowState();
}
@Override
public void windowDeactivated(WindowEvent e) {
this.saveWindowState();
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowOpened(WindowEvent e) {
}
public static void showHelp(JFrame parent) {
new HelpDialog(parent);
}
}
......@@ -36,7 +36,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package sinalgo.runtime;
import javafx.application.Platform;
import lombok.Getter;
import sinalgo.configuration.AppConfig;
import sinalgo.configuration.Configuration;
......@@ -56,7 +55,6 @@ public class GUIRuntime extends SinalgoRuntime implements ProgressBarUser {
*/
GUIRuntime() {
super();
Platform.setImplicitExit(false);
}
/**
......
......@@ -36,7 +36,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package sinalgo.runtime;
import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo;
import lombok.Getter;
import lombok.Setter;
import sinalgo.configuration.Configuration;
......@@ -213,9 +214,13 @@ public class Global {
try {
Pattern projectPattern = Pattern.compile("^(" + Configuration.getUserProjectsPackage() + "\\.\\w+).*$");
Map<String, List<String>> allImplementations = new FastClasspathScanner("-sinalgo", Configuration.getUserProjectsPackage())
Map<String, List<String>> allImplementations = new ClassGraph()
.blacklistPackages("sinalgo")
.whitelistPackages(Configuration.getUserProjectsPackage())
.scan(Math.min(Math.max(Runtime.getRuntime().availableProcessors(), 4), 1))
.getNamesOfAllStandardClasses().parallelStream()
.getAllClasses()
.parallelStream()
.map(ClassInfo::getName)
.map(projectPattern::matcher)
.filter(Matcher::matches)
.collect(Collectors.groupingBy(m -> m.group(1), Collectors.mapping(Matcher::group, Collectors.toList())));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment