diff --git a/.gitignore b/.gitignore
index 76dc67d..6a3d746 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ dist/
eclipse_bin/
*.iml
.idea/
+dependency-reduced-pom.xml
diff --git a/Jenkinsfile b/Jenkinsfile
index 10433d0..14d503c 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -6,7 +6,23 @@ pipeline {
jdk 'OpenJDK 9'
}
options { buildDiscarder(logRotator(numToKeepStr: '5')) }
+ parameters {
+ booleanParam(defaultValue: false, description: 'Perform Release', name: 'release')
+ }
stages {
+ stage('Build core') {
+ agent {
+ label "osx"
+ }
+ steps {
+ sh 'mvn -B -Dmaven.antrun.skip -Dmaven.source.skip -Dmaven.test.skip -DskipTests -DskipITs -pl coreAPI/ package'
+ }
+ post {
+ success {
+ archiveArtifacts artifacts: 'coreAPI/target/apidocs/**/*', fingerprint: true
+ }
+ }
+ }
stage('Build natives') {
parallel {
stage('Build Windows natives') {
@@ -71,7 +87,9 @@ pipeline {
agent {
label "linux"
}
+ when { branch 'master' }
steps {
+ milestone(1)
unstash 'windows-natives'
unstash 'osx-natives'
unstash 'linux-natives'
@@ -87,5 +105,40 @@ pipeline {
}
}
}
+ stage('Release') {
+ agent {
+ label "linux"
+ }
+ when {
+ expression {
+ return params.release
+ }
+ }
+ steps {
+ milestone(3)
+ unstash 'windows-natives'
+ unstash 'osx-natives'
+ unstash 'linux-natives'
+ sh 'echo $GPG_SECRET_KEYS | base64 --decode | gpg --batch --import'
+ sh 'echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust'
+ withMaven(
+ maven: 'Maven 3.5.3',
+ jdk: 'OpenJDK 9',
+ globalMavenSettingsConfig: 'global-maven-settings-ossrh',
+ mavenOpts: '-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts' //Work around for JDK9 missing cacerts
+ ) {
+ sh "mvn -P windows,linux,osx,wintab versions:set -DremoveSnapshot"
+ script {
+ VERSION_TAG = sh(script: "mvn -Dexpression=project.version help:evaluate | grep -e '^[[:digit:]]'", returnStdout: true).trim()
+ }
+ sh "git tag -a ${VERSION_TAG} -m 'Release tag ${VERSION_TAG}'"
+ sh "mvn -P windows,linux,osx,wintab,release -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy"
+ sh "mvn -P windows,linux,osx,wintab versions:revert"
+ sh "mvn -P windows,linux,osx,wintab versions:set -DnextSnapshot"
+ sh "git commit -m 'Next development release' ."
+ sh "git push --follow-tags"
+ }
+ }
+ }
}
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 6f42093..0fa03ea 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# JInput
-[](https://maven-badges.herokuapp.com/maven-central/net.java.jinput/jinput)
-[](http://www.javadoc.io/doc/net.java.jinput/jinput)
+[](https://maven-badges.herokuapp.com/maven-central/net.java.jinput/coreapi)
+[](http://www.javadoc.io/doc/net.java.jinput/coreapi)
Library for access to input devices.
diff --git a/applet/pom.xml b/applet/pom.xml
index de79023..dab664b 100644
--- a/applet/pom.xml
+++ b/applet/pom.xml
@@ -7,7 +7,7 @@
net.java.jinput
jinput-parent
- 2.0.8-SNAPSHOT
+ 2.0.9-SNAPSHOT
../
diff --git a/applet/src/main/java/net/java/games/input/applet/JInputAppletResourceLoader.java b/applet/src/main/java/net/java/games/input/applet/JInputAppletResourceLoader.java
index 63a18b5..4d2e63e 100644
--- a/applet/src/main/java/net/java/games/input/applet/JInputAppletResourceLoader.java
+++ b/applet/src/main/java/net/java/games/input/applet/JInputAppletResourceLoader.java
@@ -50,19 +50,11 @@ public class JInputAppletResourceLoader {
private int percentageDone = 0;
private String getPrivilegedProperty(final String property) {
- return (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty(property);
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(property));
}
private String setPrivilegedProperty(final String property, final String value) {
- return (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.setProperty(property, value);
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction) () -> System.setProperty(property, value));
}
public void loadResources(URL codeBase) throws IOException {
@@ -94,13 +86,13 @@ public class JInputAppletResourceLoader {
JarFile localJarFile = new JarFile(new File(tempDir, nativeJar), true);
- Enumeration jarEntries = localJarFile.entries();
+ Enumeration jarEntries = localJarFile.entries();
int totalUncompressedBytes = 0;
int totalUncompressedBytesWritten = 0;
- List entriesToUse = new ArrayList();
+ List entriesToUse = new ArrayList<>();
while(jarEntries.hasMoreElements()) {
- JarEntry jarEntry = (JarEntry)jarEntries.nextElement();
+ JarEntry jarEntry = jarEntries.nextElement();
String entryName = jarEntry.getName();
if(!entryName.startsWith("META-INF")) {
totalUncompressedBytes+=jarEntry.getSize();
@@ -116,7 +108,7 @@ public class JInputAppletResourceLoader {
}
for(int i=0;i
net.java.jinput
jinput-parent
- 2.0.8-SNAPSHOT
+ 2.0.9-SNAPSHOT
../
diff --git a/coreAPI/src/main/java/net/java/games/input/AbstractController.java b/coreAPI/src/main/java/net/java/games/input/AbstractController.java
index 02233df..5b12a8e 100644
--- a/coreAPI/src/main/java/net/java/games/input/AbstractController.java
+++ b/coreAPI/src/main/java/net/java/games/input/AbstractController.java
@@ -1,10 +1,4 @@
/*
- * %W% %E%
- *
- * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
- * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- */
-/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -35,13 +29,11 @@
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
- *****************************************************************************/
+ */
package net.java.games.input;
import java.util.Map;
-import java.util.List;
import java.util.HashMap;
-import java.util.ArrayList;
import java.io.IOException;
@@ -77,7 +69,7 @@ public abstract class AbstractController implements Controller {
/**
* Map from Component.Identifiers to Components
*/
- private final Map id_to_components = new HashMap();
+ private final Map id_to_components = new HashMap<>();
private EventQueue event_queue = new EventQueue(EVENT_QUEUE_DEPTH);
@@ -128,7 +120,7 @@ public abstract class AbstractController implements Controller {
* if no component with the specified type could be found.
*/
public final Component getComponent(Component.Identifier id) {
- return (Component)id_to_components.get(id);
+ return id_to_components.get(id);
}
/**
@@ -183,7 +175,7 @@ public abstract class AbstractController implements Controller {
setDeviceEventQueueSize(size);
event_queue = new EventQueue(size);
} catch (IOException e) {
- ControllerEnvironment.logln("Failed to create new event queue of size " + size + ": " + e);
+ ControllerEnvironment.log("Failed to create new event queue of size " + size + ": " + e);
}
}
@@ -233,7 +225,7 @@ public abstract class AbstractController implements Controller {
}
return true;
} catch (IOException e) {
- ControllerEnvironment.logln("Failed to poll device: " + e.getMessage());
+ ControllerEnvironment.log("Failed to poll device: " + e.getMessage());
return false;
}
}
diff --git a/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java b/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java
index 17208f7..6aa9ad8 100644
--- a/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java
+++ b/coreAPI/src/main/java/net/java/games/input/ControllerEnvironment.java
@@ -43,6 +43,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -70,9 +71,6 @@ import java.util.logging.Logger;
*
*/
public abstract class ControllerEnvironment {
- static void logln(String msg) {
- log(msg + "\n");
- }
static void log(String msg) {
Logger.getLogger(ControllerEnvironment.class.getName()).info(msg);
@@ -87,12 +85,17 @@ public abstract class ControllerEnvironment {
/**
* List of controller listeners
*/
- protected final ArrayList controllerListeners = new ArrayList();
+ protected final ArrayList controllerListeners = new ArrayList<>();
/**
* Protected constructor for subclassing.
*/
protected ControllerEnvironment() {
+ if(System.getProperty("jinput.loglevel") != null) {
+ String loggerName = ControllerEnvironment.class.getPackage().getName();
+ Level level = Level.parse(System.getProperty("jinput.loglevel"));
+ Logger.getLogger(loggerName).setLevel(level);
+ }
}
/**
@@ -130,9 +133,9 @@ public abstract class ControllerEnvironment {
*/
protected void fireControllerAdded(Controller c) {
ControllerEvent ev = new ControllerEvent(c);
- Iterator it = controllerListeners.iterator();
+ Iterator it = controllerListeners.iterator();
while (it.hasNext()) {
- ((ControllerListener)it.next()).controllerAdded(ev);
+ it.next().controllerAdded(ev);
}
}
@@ -142,9 +145,9 @@ public abstract class ControllerEnvironment {
*/
protected void fireControllerRemoved(Controller c) {
ControllerEvent ev = new ControllerEvent(c);
- Iterator it = controllerListeners.iterator();
+ Iterator it = controllerListeners.iterator();
while (it.hasNext()) {
- ((ControllerListener)it.next()).controllerRemoved(ev);
+ it.next().controllerRemoved(ev);
}
}
@@ -155,4 +158,4 @@ public abstract class ControllerEnvironment {
public static ControllerEnvironment getDefaultEnvironment() {
return defaultEnvironment;
}
-} // ControllerEnvironment
+}
\ No newline at end of file
diff --git a/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java b/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java
index 8540cec..4aa3521 100644
--- a/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java
+++ b/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java
@@ -1,10 +1,4 @@
/*
- * %W% %E%
- *
- * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
- * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- */
-/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -35,24 +29,20 @@
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
- *****************************************************************************/
+ */
package net.java.games.input;
+import net.java.games.util.plugins.Plugins;
+
import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.Properties;
import java.util.StringTokenizer;
import java.util.logging.Logger;
-import net.java.games.util.plugins.*;
-
/**
* The default controller environment.
*
@@ -72,42 +62,31 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
*
*/
static void loadLibrary(final String lib_name) {
- AccessController.doPrivileged(
- new PrivilegedAction() {
- public final Object run() {
+ AccessController.doPrivileged((PrivilegedAction) () -> {
String lib_path = System.getProperty("net.java.games.input.librarypath");
if (lib_path != null)
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
else
System.loadLibrary(lib_name);
return null;
- }
});
}
static String getPrivilegedProperty(final String property) {
- return (String)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty(property);
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(property));
}
static String getPrivilegedProperty(final String property, final String default_value) {
- return (String)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty(property, default_value);
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(property, default_value));
}
/**
* List of all controllers in this environment
*/
- private ArrayList controllers;
+ private ArrayList controllers;
- private Collection loadedPlugins = new ArrayList();
+ private Collection loadedPluginNames = new ArrayList<>();
/**
* Public no-arg constructor.
@@ -122,13 +101,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
public Controller[] getControllers() {
if (controllers == null) {
// Controller list has not been scanned.
- controllers = new ArrayList();
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- scanControllers();
- return null;
- }
- });
+ controllers = new ArrayList<>();
+ AccessController.doPrivileged((PrivilegedAction) () -> scanControllers());
//Check the properties for specified controller classes
String pluginClasses = getPrivilegedProperty("jinput.plugins", "") + " " + getPrivilegedProperty("net.java.games.input.plugins", "");
if(!getPrivilegedProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !getPrivilegedProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) {
@@ -154,15 +128,15 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
while(pluginClassTok.hasMoreTokens()) {
String className = pluginClassTok.nextToken();
try {
- if(!loadedPlugins.contains(className)) {
+ if(!loadedPluginNames.contains(className)) {
log.fine("Loading: " + className);
- Class ceClass = Class.forName(className);
+ Class> ceClass = Class.forName(className);
ControllerEnvironment ce = (ControllerEnvironment) ceClass.getDeclaredConstructor().newInstance();
if(ce.isSupported()) {
addControllers(ce.getControllers());
- loadedPlugins.add(ce.getClass().getName());
+ loadedPluginNames.add(ce.getClass().getName());
} else {
- logln(ceClass.getName() + " is not supported");
+ log(ceClass.getName() + " is not supported");
}
}
} catch (Throwable e) {
@@ -171,17 +145,17 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
}
}
Controller[] ret = new Controller[controllers.size()];
- Iterator it = controllers.iterator();
+ Iterator it = controllers.iterator();
int i = 0;
while (it.hasNext()) {
- ret[i] = (Controller)it.next();
+ ret[i] = it.next();
i++;
}
return ret;
}
/* This is jeff's new plugin code using Jeff's Plugin manager */
- private void scanControllers() {
+ private Void scanControllers() {
String pluginPathName = getPrivilegedProperty("jinput.controllerPluginPath");
if(pluginPathName == null) {
pluginPathName = "controller";
@@ -191,6 +165,8 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
File.separator + "lib"+File.separator + pluginPathName);
scanControllersAt(getPrivilegedProperty("user.dir")+
File.separator + pluginPathName);
+
+ return null;
}
private void scanControllersAt(String path) {
@@ -200,19 +176,19 @@ class DefaultControllerEnvironment extends ControllerEnvironment {
}
try {
Plugins plugins = new Plugins(file);
- Class[] envClasses = plugins.getExtends(ControllerEnvironment.class);
+ @SuppressWarnings("unchecked")
+ Class[] envClasses = plugins.getExtends(ControllerEnvironment.class);
for(int i=0;i findClass(String name)
throws ClassNotFoundException {
// Try loading the class from the file system.
byte[] b = loadClassData(name);
diff --git a/coreAPI/src/main/java/net/java/games/input/package.html b/coreAPI/src/main/java/net/java/games/input/package.html
index 9e26d81..58c075f 100644
--- a/coreAPI/src/main/java/net/java/games/input/package.html
+++ b/coreAPI/src/main/java/net/java/games/input/package.html
@@ -9,5 +9,6 @@ Top level package for JInput.
Use -Djinput.useDefaultPlugin=false (or net.java.games.input.useDefaultPlugin=false) to disable automatic loading of the default plugin for the platform.
Use -Djinput.plugins (or net.java.games.input.plugins) and specifiy a list of class name to over ride the plugins system. This will force the classes passed to be loaded first, then plugins will be searched for in the default manner (./controller/*.jar)
Use -Djinput.controllerPluginPath to change the path the plugins mechanism will use to search for plugin Jars.
+Use -Djinput.loglevel to change the logging level using Java util logging level strings.