diff --git a/.travis/build.sh b/.travis/build.sh index 0a540fc..3cb4db6 100644 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -14,7 +14,7 @@ fi if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - ./gradlew clean build + ./gradlew clean build minJosmVersionClasses else - ./gradlew clean build + ./gradlew clean build minJosmVersionClasses fi diff --git a/README.md b/README.md index 645c5b5..58dc0b9 100644 --- a/README.md +++ b/README.md @@ -8,34 +8,37 @@ You must be on JOSM v12712 or later for the latest build to work. ## Installation -### Build - -Clone the project and edit the build.gradle to change the josm version to your JOSM's version: - -``` -project.ext.josmVersion = '13367' +Each time you run +```bash +./gradlew installPlugin ``` +the plugin is built if needed. The resulting \*.jar file is activated for your already installed JOSM instance. +This task then fires up that JOSM instance and you can use the plugin right away. -Then run: +After that you can start JOSM however you want, the plugin will still be installed. You'd only have to repeat this, when you want to later update to a newer version of the plugin. -``` -gradle downloadJosm -``` +## Development -and +### Launch a clean JOSM instance +When you run +```bash +./gradlew runJosm ``` -gradle installPlugin -``` +a clean JOSM instance is fired up containing only the `josm-atlas` plugin. -### Launch +You do **not** have to have JOSM already installed for this: Gradle will download a JOSM executable and run that. -Open JOSM and navigate to your Plugin Preferences. +A new `JOSM_HOME` directory is created (separate from any existing ones). It persists between calls to this task, but can be cleared using the `cleanJosm` task. - Edit > Preferences > Plugins +### Build -Type `josm-atlas` into the search box and select the plugin. +Run +```bash +./gradlew build +``` +to start a full build. ## Contributing -To contribute to the project, see the [contributing guidelines](https://github.com/osmlab/atlas/blob/dev/CONTRIBUTING.md) \ No newline at end of file +To contribute to the project, see the [contributing guidelines](https://github.com/osmlab/atlas/blob/dev/CONTRIBUTING.md) diff --git a/build.gradle b/build.gradle index 96d95c2..b9bbccf 100644 --- a/build.gradle +++ b/build.gradle @@ -1,28 +1,38 @@ -buildscript { - dependencies { - classpath 'com.diffplug.spotless:spotless-plugin-gradle:3.4.0' - } -} - plugins { id 'org.openstreetmap.josm' version '0.3.2' - id "de.undercouch.download" version "3.2.0" + id 'com.diffplug.gradle.spotless' version '3.9.0' // Used to promote a staging release build // https://github.com/Codearte/gradle-nexus-staging-plugin // gradle closeAndReleaseRepository id "io.codearte.nexus-staging" version "0.8.0" + + id 'java' + id 'checkstyle' + id 'maven' + id 'maven-publish' + id 'signing' + id 'idea' } -project.ext.pluginName = 'josm-atlas' +// corresponds to POM description/group +description = "Atlas Library" +group = 'org.openstreetmap.atlas' + +archivesBaseName = 'josm-atlas' +josm { // see https://floscher.github.io/gradle-josm-plugin/kdoc/v0.3.2/gradle-josm-plugin/org.openstreetmap.josm.gradle.plugin.config/-josm-plugin-extension + josmCompileVersion '13367' + manifest { // see https://floscher.github.io/gradle-josm-plugin/kdoc/v0.3.2/gradle-josm-plugin/org.openstreetmap.josm.gradle.plugin.config/-josm-manifest + author = 'James Gage' + canLoadAtRuntime = true + description = 'Allows you to view an Atlas file as a layer.' + iconPath = 'images/dialogs/world-3.png' + mainClass = 'org.openstreetmap.atlas.AtlasReader' + minJosmVersion = '12712' + website = new URL('https://github.com/osmlab/josm-atlas') + } +} apply from: 'dependencies.gradle' -apply plugin: 'java' -apply plugin: 'checkstyle' -apply plugin: 'maven' -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: "com.diffplug.gradle.spotless" -apply plugin: 'idea' sourceCompatibility=1.8 targetCompatibility=1.8 @@ -42,14 +52,12 @@ idea { spotless { java { - importOrder(['static java', 'static javax', 'static org', 'static com', 'static scala', 'java', 'javax', 'org', 'com', 'scala']) + importOrder 'static java', 'static javax', 'static org', 'static com', 'static scala', 'java', 'javax', 'org', 'com', 'scala' removeUnusedImports() eclipse().configFile 'config/format/code_format.xml' } } -// corresponds to POM description -description = "Atlas Library" // This is to skip the tasks for which there is a skip=true environment variable def skippedTaskNames = System.getenv().findAll { key, value -> @@ -85,7 +93,7 @@ configurations dependencies { - compile packages.atlas + packIntoJar packages.atlas } tasks.withType(Test) { @@ -108,14 +116,11 @@ artifacts archives /*javadocJar,*/ sourcesJar } - /** * JOSM SPECIFIC TASKS */ -import de.undercouch.gradle.tasks.download.Download import org.gradle.internal.os.OperatingSystem - /** * This task installs the plugin in your system's JOSM plugins directory. * @@ -124,22 +129,40 @@ import org.gradle.internal.os.OperatingSystem * On macOS: * * ~/Library/JOSM/plugins/ - */ -task installPlugin(type: Copy, dependsOn: jar) { + */ +task installPlugin(type: Copy) { def destStr if(OperatingSystem.current().isMacOsX()) { destStr = "${System.getProperty('user.home')}/Library/JOSM/plugins" } else if(OperatingSystem.current().isWindows()) { destStr = "${System.getenv()['APPDATA']}/JOSM/plugins" - } else { + } else if (new File("${System.getProperty('user.home')}/.josm").exists()) { destStr = "${System.getProperty('user.home')}/.josm/plugins" + } else { + destStr = "${System.getProperty('user.home')}/.local/share/JOSM/plugins" } - println("Plugin JAR Archive Path: " + jar.archivePath) - println("Plugin JAR Destination Path: " + destStr) - from jar.archivePath + logger.lifecycle("Plugin JAR Archive Path: " + dist.outputs.files.asFileTree.files[0]) + logger.lifecycle("Plugin JAR Destination Path: " + destStr) + from tasks.dist into destStr - rename { - pluginName + '.jar' + project.afterEvaluate { + finalizedBy activatePlugin } } +/** + * Starts a JOSM instance and activates the plugin if it's not already active. + * + * The difference to the `runJosm` task is that there a completely clean instance is started up and a temporary JOSM_HOME is used. + * Here your default JOSM_HOME is used and you have to have JOSM already installed. + */ +task activatePlugin(type: Exec, dependsOn: installPlugin) { + def configFile = new File(buildDir, "addPluginConfig.xml") + doFirst { + configFile.withWriter { out -> + out.print "" + } + } + executable 'josm' + args '--load-preferences=' + configFile.toURI().toURL().toString() +} diff --git a/gradle.properties b/gradle.properties index 24c7400..40c27f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,5 @@ -group=org.openstreetmap.atlas version=4.0.0-SNAPSHOT -plugin.class=org.openstreetmap.atlas.AtlasReader -plugin.compile.version=13367 -plugin.description=Allows you to view an Atlas file as a layer. -plugin.main.version=12712 -plugin.author=James Gage -plugin.canloadatruntime=true -# plugin.early=false -plugin.icon=images/dialogs/world-3.png -# plugin.requires= -# plugin.stage=50 - maven2_url=https://oss.sonatype.org/service/local/staging/deploy/maven2/ snapshot_url=https://oss.sonatype.org/content/repositories/snapshots/ project_name="JOSM plugin to view Atlas files"