Skip to content

Commit

Permalink
improved version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
s1mpl3x committed Sep 27, 2014
1 parent 0130d7b commit 390b0a6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<version>4.3.3</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.2.3</version>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ private ChannelManager() {
}

public void addListener(final ChannelEventListener listener) {
SkadiLogging.log("added channel listener: " + listener.getListenerName());
this.listeners.add(listener);
}

Expand Down
27 changes: 19 additions & 8 deletions src/main/java/eu/over9000/skadi/util/SkadiVersionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;

import eu.over9000.skadi.gui.SkadiGUI;
import eu.over9000.skadi.logging.SkadiLogging;

Expand All @@ -52,19 +54,25 @@ public static void checkVersion() {

@Override
public void run() {
final String localVersion = this.getClass().getPackage().getImplementationVersion();
final String localVersionString = this.getClass().getPackage().getImplementationVersion();

if (localVersion == null) {
if (localVersionString == null) {
SkadiLogging.log("could not find local Version, will skip version check");
return;
}

SkadiLogging.log("starting " + localVersion);
SkadiLogging.log("starting " + localVersionString);

final String remoteVersion = SkadiVersionRetriever.getLatestVersion();

if (!remoteVersion.equals(localVersion)) {

final String currentVersionString = SkadiVersionRetriever.getLatestVersion();

final DefaultArtifactVersion currentVersion = new DefaultArtifactVersion(currentVersionString);
final DefaultArtifactVersion localVersion = new DefaultArtifactVersion(localVersionString);

final int result = currentVersion.compareTo(localVersion);

if (result > 0) { // newer version available
final String updateMsg = "There is a newer version (" + remoteVersion
+ ") of Skadi available. You can download it from: ";
SkadiLogging.log(updateMsg + SkadiVersionChecker.SKADI_RELEASES_URL);
Expand Down Expand Up @@ -97,12 +105,15 @@ public void mouseClicked(final MouseEvent event) {

}
});
} else {

} else if (result == 0) { // latest release
SkadiLogging.log("This is the latest version.");

} else { // newer than latest release
SkadiLogging.log("This version is newer than the lastest public release version "
+ currentVersionString + ", use with care");
}

}
}).start();
}

}

0 comments on commit 390b0a6

Please sign in to comment.