diff --git a/.travis.yml b/.travis.yml index ffa23fd..cb87a14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ jdk: - openjdk8 - oraclejdk8 - oraclejdk9 -script: ./gradlew build compileMinJosmVersion +script: ./gradlew build compileJava_minJosm deploy: - provider: releases api-key: @@ -21,14 +21,13 @@ jobs: include: - stage: i18n language: python - python: "3.5" - install: pip install git+https://github.com/transifex/transifex-client.git@a706ba0cb910e66e852010bcd742221363c7e8be#egg=transifex-client + python: "3.6" + install: pip install git+https://github.com/transifex/transifex-client.git@c8434afc44c74fa36400dc0574f5b0b25580e1e0#egg=transifex-client script: | if [ ! -z "$TRANSIFEX_TOKEN" ]; then + export PATH="$PATH:$HOME/.local/bin" ./gradlew generatePot - tx --token="$TRANSIFEX_TOKEN" --force-save --no-interactive init - git checkout HEAD .tx/config - tx push -s --no-interactive + TX_TOKEN="$TRANSIFEX_TOKEN" tx push -s --no-interactive fi stages: diff --git a/build.gradle b/build.gradle index c512ead..f458d6f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,9 @@ plugins { - id "org.openstreetmap.josm" version "0.3.1" - id 'eclipse' - id 'idea' + id "java" + id "org.openstreetmap.josm" version "0.5.0" } -apply from: 'gradle/version-functions.gradle' sourceCompatibility = '1.8' -version = getVersionName() sourceSets { main { @@ -25,17 +22,20 @@ sourceSets { archivesBaseName = 'fieldpapers' josm { i18n { - pathTransformer = getGithubPathTransformer('fieldpapers/josm-fieldpapers') + pathTransformer = getPathTransformer("github.com/fieldpapers/josm-fieldpapers/blob") } manifest { oldVersionDownloadLink 10273, 'v0.4.2', new URL('https://github.com/floscher/josm-fieldpapers/releases/download/v0.4.2/fieldpapers.jar') } } -eclipse.project.name = 'JOSM-fieldpapers' -eclipseClasspath.dependsOn cleanEclipseClasspath -eclipseProject.dependsOn cleanEclipseProject - tasks.withType(Javadoc) { failOnError false } + +tasks.withType(JavaCompile) { + options.compilerArgs += [ + "-Xlint:all", + "-Xlint:-serial", + ] +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 801cfa8..c149782 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,8 +5,8 @@ plugin.icon=images/preferences/fieldpapers.png plugin.link=http://wiki.openstreetmap.org/index.php/JOSM/Plugins/FieldPapers # Minimum required JOSM version to run this plugin, choose the lowest version possible that is compatible. # You can check if the plugin compiles against this version by executing `./gradlew minJosmVersionClasses`. -plugin.main.version=12643 +plugin.main.version=14140 # Version of JOSM against which the plugin is compiled # Please check, if the specified version is available for download from https://josm.openstreetmap.de/download/ . # If not, choose the next higher number that is available, or the gradle build will break. -plugin.compile.version=13265 +plugin.compile.version=14178 diff --git a/gradle/version-functions.gradle b/gradle/version-functions.gradle deleted file mode 100644 index 92d055b..0000000 --- a/gradle/version-functions.gradle +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Returns the current value returned by the bash command `git describe --always --dirty`. - */ -ext.getVersionName = { -> - def resultStream = new ByteArrayOutputStream() - def nullOut = new ByteArrayOutputStream() - try { - exec { - commandLine 'git', 'describe', '--always', '--dirty', '--tags' - standardOutput = resultStream - errorOutput = nullOut - } - return resultStream.toString().trim() - } catch (Exception e) { - return '‹unknown›' - } -} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6b25d5f..b10568f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,5 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip -distributionSha256Sum=5c07b3bac2209fbc98fb1fdf6fd831f72429cdf8c503807404eae03d8c8099e5 \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java b/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java index 7becd3e..2f11f7d 100644 --- a/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java +++ b/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersAddLayerAction.java @@ -17,7 +17,6 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; -import org.openstreetmap.josm.Main; import org.openstreetmap.josm.actions.JosmAction; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.coor.LatLon; @@ -33,7 +32,7 @@ public class FieldPapersAddLayerAction extends JosmAction { public FieldPapersAddLayerAction() { - super(tr("Scanned Map..."), "fieldpapers", + super(tr("FieldPapers snapshot"), "fieldpapers", tr("Display a map that was previously scanned and uploaded to fieldpapers.org"), null, false); } @@ -42,11 +41,11 @@ public void actionPerformed(ActionEvent e) { // snapshot URL selection panel.add(new JLabel(tr("Enter a fieldpapers.org snapshot URL to download from")), GBC.eol()); - JosmTextField snapshotAddress = new JosmTextField(Main.pref.get("fieldpapers.last-used-id")); + JosmTextField snapshotAddress = new JosmTextField(FieldPapersPlugin.LAST_USED_ID.get()); snapshotAddress.setToolTipText(tr("Enter an URL from where scanned map should be downloaded")); panel.add(snapshotAddress, GBC.eop().fill(GBC.BOTH)); - ExtendedDialog dialog = new ExtendedDialog(Main.parent, + ExtendedDialog dialog = new ExtendedDialog(MainApplication.getMainFrame(), tr("Download Snapshot"), tr("Download"), tr("Cancel")) .setContent(panel, false) @@ -64,7 +63,7 @@ public void openUrl(String url) { if (url == null || url.equals("")) return; if (!url.startsWith("http")) { - url = Main.pref.get("fieldpapers-base-url", "http://fieldpapers.org/") + "snapshots/" + url; + url = FieldPapersPlugin.BASE_URL.get() + "snapshots/" + url; } try { @@ -88,7 +87,7 @@ public void openUrl(String url) { double north = bounds.getJsonNumber(3).doubleValue(); // save this atlas as the - Main.pref.put("fieldpapers.last-used-id", id); + FieldPapersPlugin.LAST_USED_ID.put(id); Bounds b = new Bounds(new LatLon(south, west), new LatLon(north, east)); @@ -97,7 +96,7 @@ public void openUrl(String url) { } catch (IOException ex) { Logging.error(ex); - JOptionPane.showMessageDialog(Main.parent,tr("Could not read information for the id \"{0}\" from fieldpapers.org", url)); + JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Could not read information for the id \"{0}\" from fieldpapers.org", url)); } } diff --git a/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersPlugin.java b/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersPlugin.java index 0d85562..23a5c8b 100644 --- a/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersPlugin.java +++ b/src/org/openstreetmap/josm/plugins/fieldpapers/FieldPapersPlugin.java @@ -1,17 +1,13 @@ package org.openstreetmap.josm.plugins.fieldpapers; -import static org.openstreetmap.josm.gui.help.HelpUtil.ht; -import static org.openstreetmap.josm.tools.I18n.tr; - -import java.awt.event.KeyEvent; - -import javax.swing.JMenu; import javax.swing.JMenuItem; +import org.openstreetmap.josm.data.Preferences; +import org.openstreetmap.josm.data.preferences.StringProperty; import org.openstreetmap.josm.gui.MainApplication; -import org.openstreetmap.josm.gui.MainMenu; import org.openstreetmap.josm.plugins.Plugin; import org.openstreetmap.josm.plugins.PluginInformation; +import org.openstreetmap.josm.tools.Logging; /** * Main class for the field papers plugin. @@ -20,14 +16,22 @@ * @author Frederik Ramm * */ -public class FieldPapersPlugin extends Plugin -{ - public FieldPapersPlugin(PluginInformation info) - { +public class FieldPapersPlugin extends Plugin { + public static final StringProperty LAST_USED_ID = new StringProperty("fieldpapers.last-used-id", ""); + + public static final StringProperty BASE_URL = new StringProperty("fieldpapers.base-url", "http://fieldpapers.org/"); + + public FieldPapersPlugin(PluginInformation info) { super(info); - MainMenu menu = MainApplication.getMenu(); - JMenu fpMenu = menu.addMenu("Field Papers", tr("Field Papers"), KeyEvent.VK_K, menu.getDefaultMenuPos(), ht("/Plugin/FieldPapers")); - fpMenu.add(new JMenuItem(new FieldPapersAddLayerAction())); + // Migrate old setting, remove this in one of the next versions. + final String oldValue = Preferences.main().get("fieldpapers-base-url"); + if (!"".equals(oldValue) && !BASE_URL.isSet()) { + BASE_URL.put(oldValue); + Preferences.main().put("fieldpapers-base-url", null); + Logging.info("Preference `fieldpapers-base-url`={0} was renamed to `fieldpapers.base-url`!", oldValue); + } + + MainApplication.getMenu().imageryMenu.add(new JMenuItem(new FieldPapersAddLayerAction())); } }