Skip to content

Commit 4cac88f

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 23a4283 + 11385ef commit 4cac88f

File tree

11 files changed

+79
-182
lines changed

11 files changed

+79
-182
lines changed

README.md

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ Add `sbt-imagej` as a dependency in `project/imagej.sbt`:
2727
addSbtPlugin("net.sf.ij-plugins" % "sbt-imagej" % "2.0.1")
2828
```
2929

30-
To use `sbt-imagej` you need to enable it in your project configuration,
31-
if you're using `build.sbt` add this:
32-
33-
```scala
34-
enablePlugins(SbtImageJ)
35-
```
30+
Once added to the project the plugin will be enabled by default.
3631

3732
Now you'll have a new `ijRun` task which will compile your project,
3833
pack your class files and resources in a jar, copy that jar and dependencies to local
@@ -45,7 +40,6 @@ There is also a task that only copies the jar and dependencies to to the plugins
4540
> ijPrepareRun
4641

4742
It is useful if you want to have your own run configuration, for instance executed by your IDE.
48-
Look in the `example` directory to see how it can be used in IntelliJ IDEA or Eclipse.
4943

5044
### Configuration
5145

@@ -66,10 +60,8 @@ Consider example settings:
6660

6761
```scala
6862
ijRuntimeSubDir := "sandbox"
69-
7063
ijPluginsSubDir := "my-plugin"
71-
72-
ijExclusions += """some\.jar"""
64+
ijExclusions += """some\.jar"""
7365
```
7466

7567
This will set ImageJ runtime directory to `sandbox` and directory where your plugins will be
@@ -83,7 +75,7 @@ where all jars will be copied. `ijPluginsDir` is intended to be read-only. It ca
8375
for instance, in `cleanFiles += ijPluginsDir.value`. By default, it is computed from
8476
`ijPluginsSubDir` and `ijRuntimeSubDir`. You should not reassign it.
8577

86-
### Multi-Module Projects###
78+
### Multi-Module Projects
8779

8880
If you are using a multi-module projects and would like to include dependent project jars in the plugins directory
8981
you need to take extra steps. When a SBT creates a classpath from dependent projects it exports a directory containing its
@@ -102,8 +94,8 @@ You need to add `exportsJars := true` to every dependent projects in your build.
10294
Example Project
10395
---------------
10496

105-
You can find example project in sub-directory [example].
106-
It contains SBT setup, two ImageJ plugins, and a workaround to run SBT tasks from IDEA and Eclipse.
97+
You can find example project in sub-directory [example].
98+
It contains a simple project with with two ImageJ plugins.
10799

108100

109101
Tips and Tricks
@@ -137,39 +129,52 @@ ijPrepareRun := ijPrepareRun.value ++ {
137129
}
138130
```
139131

140-
### Running SBT tasks at part of IDEA or Eclipse build ###
141-
142-
[IntelliJ IDEA](https://www.jetbrains.com/idea/) can load SBT projects using its Scala plugin.
143-
To execute SBT tasks before run/debug you will additionally need SBT plugin.
144-
You can setup your run configuration as described in [example/README.md](example).
145-
146-
Eclipse does noy currently support SBT tasks, but you can execute them indirectly be calling them from Ant.
147-
148-
```xml
149-
<target name="sbt-imagej-prepare-run"
150-
description="Run SBT task 'prepareRun' that prepares ImageJ plugins directory">
151-
<property environment="env"/>
152-
<fail unless="env.SBT_HOME"
153-
message="SBT_HOME system variable must be defined and point to directory containing 'sbt-launch.jar'"/>
154-
<property name="sbt-launch.jar" location="${env.SBT_HOME}/bin/sbt-launch.jar"/>
155-
156-
<java dir="${basedir}"
157-
jar="${sbt-launch.jar}"
158-
fork="true"
159-
failonerror="true">
160-
<jvmarg line="-Dfile.encoding=UTF8 -Xmx1G -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m
161-
-Djava.net.useSystemProxies=true"/>
162-
<arg line="ijPrepareRun"/>
163-
</java>
164-
</target>
165-
```
132+
### Running using SBT
133+
134+
1. Open command prompt
135+
2. Change directory to one containing this project
136+
3. Execute command `sbt ijRun`
137+
138+
### Running SBT tasks at part of IntelliJ IDEA build
139+
140+
[IntelliJ IDEA](https://www.jetbrains.com/idea/), with Scala plugin, can directly load SBT projects.
141+
You can then execute sbt tasks to build and copy needed jars to run your plugins in ImageJ.
142+
143+
#### Option 1: Run `ijRun` task as "Run Configuration"
144+
145+
1. From the menu select "Run" > "Edit Configurations..."
146+
2. Click `+` (add new configuration) and select "sbt Task" as configuration type
147+
3. Give the configuration a name, say "ImageJ"
148+
4. Under "Tasks" type `ijRun`
149+
5. Make sure that working directory points to your module directory
150+
151+
Now you have new run configuration that will build your code, package jars, and start ImageJ with your plugins.
152+
153+
The downside of this method is that IntelliJ will not let you debug you code if you start it this way.
154+
155+
#### Option 2: Add `ijPrepareRun` to a typical application run configuration
156+
157+
The idea is to create a regular application run configuration and execute `sbt ijPrepareRun` to setup runtime directories:
166158

167-
You can find complete [build.xml](example/build.xml) in the [example](example) project.
159+
1. From the menu select "Run" > "Edit Configurations..."
160+
2. Click `+` (add new configuration) and select "Application" as configuration type
161+
3. Give you configuration a name, say "ImageJ"
162+
4. In "Main class:" type `ij.ImageJ`
163+
5. In "Working directory:" select subdirectory "sandbox" of your module directory (or a directory you defined in `ijRuntimeSubDir`)
164+
6. Select relevant project module.
165+
7. In "Before lunch:" select `+` and then select "Run External Tool"
166+
8. In "External Tool" window select `+` to define how to execute `sbt ijPrepareRun`
167+
9. Give the external toll configuration some name.
168+
10. In "Program:" type `sbt`
169+
11. In "Arguments:" type `ijPrepareRun`
170+
12. In "Working directory:" select your module directory
171+
13. Click "OK" a couple of times to close dialogs
168172

173+
Now you have definition of an application run configuration that will run ImageJ, before the run SBT will be called to prepare plugin jars and copy them to plugins subdirectory.
169174

170175
License
171176
-------
172177

173-
Copyright (c) 2013-2017 Jarek Sacha
178+
Copyright (c) 2013-2018 Jarek Sacha
174179

175180
Published under GPLv3, see LICENSE file.

build.sbt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
// @formatter:off
2+
23
sbtPlugin := true
34

45
name := "sbt-imagej"
56
organization := "net.sf.ij-plugins"
6-
version := "2.0.1"
7+
version := "2.0.2-SNAPSHOT"
78
description := "SBT plugin that helps create runtime directory structure for ImageJ plugin development."
89
homepage := Some(url("http://github.com/jpsacha/sbt-imagej"))
910
organizationHomepage := Some(url("http://ij-plugins.sf.net"))
1011
startYear := Some(2013)
1112
licenses := Seq("GPLv3" -> url("http://www.gnu.org/licenses/gpl.html"))
1213

13-
scalaVersion := "2.10.6"
14+
scalaVersion := "2.12.8"
1415

1516
scalacOptions := Seq("-deprecation", "-unchecked")
1617

17-
publishArtifact in(Test, packageBin) := false
18-
publishArtifact in(Test, packageDoc) := false
19-
publishArtifact in(Test, packageSrc) := false
20-
2118
shellPrompt in ThisBuild := { state => "sbt:"+Project.extract(state).currentRef.project + "> " }
22-
23-
publishTo := version {
24-
version: String =>
25-
val nexus = "https://oss.sonatype.org/"
26-
if (version.contains("-SNAPSHOT"))
27-
Some("snapshots" at nexus + "content/repositories/snapshots")
28-
else
29-
Some("releases" at nexus + "service/local/staging/deploy/maven2")
30-
}.value

example/README.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,3 @@ implemented in Scala, the second in Java.
2424
* `example/src/main/java/effects/Vignette.java` - a plugin adding darken border to a color image.
2525
* `example/src/main/resources/plugins.config` - manifest that instructs ImageJ in which menu to
2626
install the plugins.
27-
28-
There is also an Ant file that helps to integrate `sbt-imagej` into a build performed by an IDE
29-
(till they can execute SBT tasks directly). See details in the next section.
30-
31-
* `example/build.xml` - Ant configuration that has a target to call SBT task `ijPrepareRun`
32-
33-
Running
34-
-------
35-
36-
The simplest way to build and run the example is to use SBT. It also can be used from IntelliJ
37-
IDEA, Eclipse, and NetBeans. In all cases it assumes that you have [SBT](http://www.scala-sbt.org/) installed
38-
on your system.
39-
40-
### Using SBT ###
41-
42-
1. Open command prompt
43-
2. Change directory to one containing this project
44-
3. Execute command `sbt ijRun`
45-
46-
### Using IntelliJ IDEA ###
47-
48-
We assume here that you have [IntelliJ IDEA](http://www.jetbrains.com/idea/) 14 installed together
49-
with the Scala and SBT plugins. Scala plugin supports loading SBT projects into IDEA.
50-
The SBT plugin adds ability to execute SBT tasks before run/debug.
51-
52-
1. Start IDEA
53-
1. Select "Import Project" and load the `example/build.sbt`. This will let you edit and build
54-
the project.
55-
1. To run ImageJ with the custom plugin you need to invoke `ijPrepareRun` tasks before running ImageJ.
56-
1. Click `Run` > `Edit Configurations`
57-
1. Add new application configuration, call it for instance, `ImageJ`
58-
1. Set main class to `ij.ImageJ`
59-
1. Set "Working directory" to `example/sandbox`
60-
1. Click on "+" under "Before lunch", select "SBT", in the combo box type `ijPrepareRun`, hit Enter (it is important), then click on OK.
61-
1. Now you can run the new configuration. It will build the project, call SBT
62-
to package and copy JARs, then run ImageJ with new plugins installed.
63-
64-
65-
### Using Eclipse ###
66-
67-
You can generate Eclipse project using [sbteclipse](https://github.com/typesafehub/sbteclipse)
68-
plugin. Then go through steps similar as described above for IDEA. The only significant difference
69-
is that in Eclipse you add the `sbt-imagej-prepare-run` Ant target by defining new Ant builder.
70-

example/build.sbt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ name := "sbt-imagej-example"
22
organization := "ij-plugins.sf.net"
33
version := "2.0.1"
44

5-
scalaVersion := "2.12.3"
5+
scalaVersion := "2.12.8"
66

7-
libraryDependencies += "net.imagej" % "ij" % "1.51p"
7+
libraryDependencies += "net.imagej" % "ij" % "1.52i"
88

99
fork := true
1010

11-
// Enable and customize `sbt-imagej` plugin
12-
enablePlugins(SbtImageJ)
11+
// Customize `sbt-imagej` plugin
1312
ijRuntimeSubDir := "sandbox"
1413
ijPluginsSubDir := "ij-plugins"
1514
ijCleanBeforePrepareRun := true

example/build.xml

Lines changed: 0 additions & 71 deletions
This file was deleted.

example/project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sbt.version=0.13.16
1+
sbt.version=1.2.7
22

example/project/plugin.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
22

3-
addSbtPlugin("net.sf.ij-plugins" % "sbt-imagej" % "2.0.1")
3+
addSbtPlugin("net.sf.ij-plugins" % "sbt-imagej" % "2.0.2-SNAPSHOT")

project/build.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
sbt.version=0.13.16
2-
1+
sbt.version=1.2.7

project/sbt-sonatype.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// [https://github.com/xerial/sbt-sonatype]
2-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
3-
4-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
2+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
3+
// [https://github.com/sbt/sbt-pgp]
4+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")

publish.sbt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @formatter:off
2+
3+
publishMavenStyle := true
4+
5+
publishArtifact in Test := false
6+
7+
publishTo := version {
8+
version: String =>
9+
val nexus = "https://oss.sonatype.org/"
10+
if (version.contains("-SNAPSHOT"))
11+
Some("snapshots" at nexus + "content/repositories/snapshots")
12+
else
13+
Some("releases" at nexus + "service/local/staging/deploy/maven2")
14+
}.value
15+
16+
pomIncludeRepository := { _ => false }

0 commit comments

Comments
 (0)