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

Upgrade dependencies #113

Merged
merged 5 commits into from
Mar 19, 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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- [PR #113](https://github.com/kaklakariada/portmapper/pull/113)
- Upgrade dependencies
- Fixed too small font size in log view on high resolution screens
- Fixed static code analysis warnings

## [2.2.2] - 2021-03-06

* No changes, move deployment from JCenter to Maven Central.
- No changes, move deployment from JCenter to Maven Central.

## [2.2.1] - 2020-07-11

Expand Down
96 changes: 24 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Run `java -version` on the command line to check the default version. If this re

If this does not help: run PortMapper from the command line using the command above and create a [ticket](https://github.com/kaklakariada/portmapper/issues) containing the complete error message and stack trace.

### PortMapper fails to start with ClassNotFoundException
#### java.lang.ClassNotFoundException: /language=en

```
$ java -Duser.language=en -jar portmapper.jar
Expand All @@ -91,6 +91,25 @@ This error occurs when using PowerShell to start PortMapper with a system proper
$ java "-Duser.language=en" -jar portmapper.jar
```

#### java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

```
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.chris.portmapper.PortMapperStarter.<clinit>(PortMapperStarter.java:26)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
```

You probably try to run a `.jar` that does not contain the required dependencies. Please either

* [Download UPnP PortMapper from SourceForge](https://sourceforge.net/projects/upnp-portmapper/files/latest/download)
* When building PortMapper yourself
* Build and execute PortMapper using a single command `./gradlew run`
* Build PortMapper using command `./gradlew build` and execute JAR `*-all.jar` that includes all dependencies: `java -jar build/libs/portmapper-$version-all.jar`

### Router not found

- Check if UPnP is activated in your router's settings.
Expand Down Expand Up @@ -245,77 +264,6 @@ Create an empty directory before starting, else PortMapper will fail with an err

The configuration files are only used when PortMapper runs in GUI mode. When running in command line mode the configuration files are not used. Instead you must specify all settings as command line arguments.

## Development

### Using PortMapper as a library

PortMapper is available as a Maven dependency at [Maven Central](https://repo1.maven.org/maven2/com/github/kaklakariada/portmapper/). Use the following coordinates:

* Gradle: `com.github.kaklakariada:portmapper:2.2.2`
* Maven:

```xml
<dependency>
<groupId>com.github.kaklakariada</groupId>
<artifactId>portmapper</artifactId>
<version>2.2.2</version>
</dependency>
```

**Important:** Due to the [deprecation of JCenter](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/) new versions will be published to [Maven Central](https://search.maven.org/artifact/com.github.kaklakariada/portmapper). In your build script please use

```groovy
repositories {
mavenCentral()
}
```

### Building PortMapper

Build PortMapper on the command line:

```bash
$ git clone https://github.com/kaklakariada/portmapper.git
$ cd portmapper
$ ./gradlew build
$ java -jar build/libs/portmapper-*.jar
```

### Generate license header for added files

```bash
$ ./gradlew licenseFormat
```

### Check if dependencies are up-to-date

```bash
$ ./gradlew dependencyUpdates
```

### Publish to Maven Central

1. Add the following to your `~/.gradle/gradle.properties`:

```properties
ossrhUsername=<your maven central username>
ossrhPassword=<your maven central passwort>

signing.keyId=<gpg key id (last 8 chars)>
signing.password=<gpg key password>
signing.secretKeyRingFile=<path to secret keyring file>
```

2. Increment version number in `build.gradle` and `README.md`, commit and push.
3. Run the following command:

```bash
$ ./gradlew clean check build publish closeAndReleaseRepository --info
```

4. Create a new [release](https://github.com/kaklakariada/portmapper/releases) on GitHub.
5. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/com/github/kaklakariada/portmapper/).

## Participate

Your feedback is most welcome at the project page:
Expand All @@ -325,3 +273,7 @@ Your feedback is most welcome at the project page:
- Need help using the UPnP PortMapper? Post a message in the Forum!
- Want to help with developing? Contact [me](http://sourceforge.net/u/christoph/profile/) via [SourceForge.net](http://sourceforge.net/u/christoph/profile/send_message)!
- Want to send me a mail? Use `christoph at users.sourceforge.net`!

## Development

See [developer guide](./doc/developer_guide.md).
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ plugins {
id 'maven-publish'
id 'jacoco'
id "com.github.hierynomus.license" version "0.16.1"
id "org.sonarqube" version "3.3"
id 'com.github.johnrengelman.shadow' version '7.1.1'
id "org.sonarqube" version "4.0.0.2929"
id 'com.github.johnrengelman.shadow' version '8.1.0'
id 'io.codearte.nexus-staging' version '0.30.0'
id 'com.github.ben-manes.versions' version '0.39.0'
id 'com.github.ben-manes.versions' version '0.46.0'
}

repositories {
Expand Down Expand Up @@ -79,9 +79,9 @@ artifacts {

dependencies {
implementation 'args4j:args4j:2.33'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'org.slf4j:jul-to-slf4j:1.7.32'
implementation 'ch.qos.logback:logback-classic:1.2.9'
implementation 'org.slf4j:slf4j-api:2.0.7'
implementation 'org.slf4j:jul-to-slf4j:2.0.7'
implementation 'ch.qos.logback:logback-classic:1.4.6'
implementation 'com.miglayout:miglayout-swing:11.0'
implementation 'org.jdesktop.bsaf:bsaf:1.9.2'
implementation ':sbbi-upnplib:1.0.4'
Expand All @@ -91,7 +91,7 @@ dependencies {
runtimeOnly 'commons-jxpath:commons-jxpath:1.1' // sbbi

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:4.2.0'
testImplementation 'org.mockito:mockito-core:5.2.0'
}

license {
Expand Down
65 changes: 65 additions & 0 deletions doc/developer_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

# Developer Guide

## Using PortMapper as a library

PortMapper is available as a Maven dependency at [Maven Central](https://repo1.maven.org/maven2/com/github/kaklakariada/portmapper/). Use the following coordinates:

* Gradle: `com.github.kaklakariada:portmapper:2.2.2`
* Maven:

```xml
<dependency>
<groupId>com.github.kaklakariada</groupId>
<artifactId>portmapper</artifactId>
<version>2.2.2</version>
</dependency>
```

**Important:** The version published to Maven Central is intended to be used as a library in other programs, not as a standalone program. If you don't know what this means you probably want to [download UPnP PortMapper from SourceForge](https://sourceforge.net/projects/upnp-portmapper/files/latest/download).

## Building PortMapper

Build PortMapper on the command line:

```bash
git clone https://github.com/kaklakariada/portmapper.git
cd portmapper
./gradlew build
java -jar build/libs/portmapper-*.jar
```

## Generate license header for added files

```bash
./gradlew licenseFormat
```

## Check if dependencies are up-to-date

```bash
./gradlew dependencyUpdates
```

## Publish to Maven Central

1. Add the following to your `~/.gradle/gradle.properties`:

```properties
ossrhUsername=<your maven central username>
ossrhPassword=<your maven central passwort>

signing.keyId=<gpg key id (last 8 chars)>
signing.password=<gpg key password>
signing.secretKeyRingFile=<path to secret keyring file>
```

2. Increment version number in `build.gradle` and `README.md`, commit and push.
3. Run the following command:

```bash
./gradlew clean check build publish closeAndReleaseRepository --info
```

4. Create a new [release](https://github.com/kaklakariada/portmapper/releases) on GitHub.
5. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/com/github/kaklakariada/portmapper/).
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/chris/portmapper/MacSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
*/
public class MacSetup {

private MacSetup() {
// Not instantiable
}

public static void setupMac() {
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "UPnP PortMapper");
System.setProperty("apple.laf.useScreenMenuBar", "true");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/chris/portmapper/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Settings implements Serializable {

private static final long serialVersionUID = -1349121864190290050L;

public final static String PROPERTY_PORT_MAPPING_PRESETS = "presets";
public static final String PROPERTY_PORT_MAPPING_PRESETS = "presets";

private List<PortMappingPreset> presets;
private boolean useEntityEncoding;
Expand Down Expand Up @@ -75,7 +75,7 @@ public void removePresets(final PortMappingPreset selectedPreset) {
new ArrayList<>(this.presets));
}

public void savePreset(final PortMappingPreset portMappingPreset) {
public void savePreset() {
this.propertyChangeSupport.firePropertyChange(PROPERTY_PORT_MAPPING_PRESETS, null,
new ArrayList<>(this.presets));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.WindowConstants;

import org.chris.portmapper.PortMapperApp;
import org.chris.portmapper.model.Protocol;
Expand Down Expand Up @@ -83,7 +84,7 @@ public AddPortRangeDialog(final PortMapperApp app, final EditPresetDialog editPr
this.setContentPane(this.getDialogPane());

this.getRootPane().setDefaultButton(okButton);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setName(DIALOG_NAME);
this.setModal(true);
this.pack();
Expand Down
Loading