{"id":16917029,"url":"https://github.com/jpsacha/sbt-imagej","last_synced_at":"2026-03-07T04:05:07.506Z","repository":{"id":10927352,"uuid":"13230386","full_name":"jpsacha/sbt-imagej","owner":"jpsacha","description":"sbt-imagej is an SBT (Simmple Build Tool) plugin that that helps with development of ImageJ plugins","archived":false,"fork":false,"pushed_at":"2018-12-12T23:56:40.000Z","size":232,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T13:38:50.372Z","etag":null,"topics":["imagej","imagej-plugins","sbt-imagej","sbt-plugin","scala"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpsacha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-30T23:37:04.000Z","updated_at":"2018-12-12T23:56:42.000Z","dependencies_parsed_at":"2022-09-15T05:11:00.026Z","dependency_job_id":null,"html_url":"https://github.com/jpsacha/sbt-imagej","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpsacha%2Fsbt-imagej","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpsacha%2Fsbt-imagej/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpsacha%2Fsbt-imagej/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpsacha%2Fsbt-imagej/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpsacha","download_url":"https://codeload.github.com/jpsacha/sbt-imagej/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248383989,"owners_count":21094650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["imagej","imagej-plugins","sbt-imagej","sbt-plugin","scala"],"created_at":"2024-10-13T19:32:23.464Z","updated_at":"2026-03-07T04:05:02.461Z","avatar_url":"https://github.com/jpsacha.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"sbt-imagej\n==========\n\nsbt-imagej is an [SBT](http://www.scala-sbt.org/) (Simple Build Tool) plugin that that helps with development of\n[ImageJ](http://rsbweb.nih.gov/ij/) plugins (those are different than SBT plugins).\nIt works for Scala as well as Java, or mix of both.\n\nThe main task is `ijRun` it packages the ImageJ plugin and helps test the plugin from within ImageJ:\n\n1. Builds your ImageJ plugin and packages it as jar.\n2. Creates directory structure expected by ImageJ runtime.\n3. Copies the plugin jar to ImageJ plugins directory, along with all dependencies.\n4. Starts ImageJ instance that is aware of the new plugin location,\n   so you can interactively test your plugin from within ImageJ.\n\nThe other task `ijPrepareRun` is intended for integration with IDEs, like IntelliJ IDEA and Eclipse.\nSee also blog post [Developing ImageJ plugins with SBT using sbt-imagej](https://codingonthestaircase.wordpress.com/2014/11/23/developing-imagej-plugins-with-sbt-using-sbt-imagej/).\n\n`sbt-imagej` requires SBT 1.0 or newer.\n\nUsage\n-----\n\nAdd `sbt-imagej` as a dependency in `project/imagej.sbt`:\n\n```scala\naddSbtPlugin(\"net.sf.ij-plugins\" % \"sbt-imagej\" % \"2.1.0\")\n```\n\nOnce added to the project the plugin will be enabled by default.\n\nNow you'll have a new `ijRun` task which will compile your project,\npack your class files and resources in a jar, copy that jar and dependencies to local\nImageJ's plugins directory, and run ImageJ\n\n    \u003e ijRun\n\nThere is also a task that only copies the jar and dependencies to to the plugins directory\n\n    \u003e ijPrepareRun\n\nIt is useful if you want to have your own run configuration, for instance executed by your IDE.\n\n### Configuration\n\nThere are a couple of settings you can use to customize `sbt-imagej` plugins:\n\n* `ijRuntimeSubDir` - Location of ImageJ runtime directory relative to base directory.\n  Default value is `sandbox`.\n* `ijPluginsSubDir` - Subdirectory of the `plugins` directory, where all `jar`s will be copied.\n  Default is `jars`.\n* `ijExclusions` - List of regex expressions that match JARs that will be excluded from the plugins directory.\n  Default excludes ImageJ jar, source jars, and javadoc/scaladoc jars.\n* `ijCleanBeforePrepareRun` -  If `true` the plugins directory will be cleaned (deleted) before it\n  is populated by `ijPrepareRun` task. This is useful if jar names change during build,\n  for instance, due to versioning. If old jars with different names will not be removed ImageJ will\n  complain about duplicate plugins. Default value is `false` (for safety).\n\nConsider example settings:\n\n```scala\nijRuntimeSubDir := \"sandbox\"\nijPluginsSubDir := \"my-plugin\"\nijExclusions    += \"\"\"some\\.jar\"\"\"\n```\n\nThis will set ImageJ runtime directory to `sandbox` and directory where your plugins will be\ncopied to `sandbox/plugins/my-plugin`. Additionally exclude the `some.jar` from being\ncopied to that directory. Note that for exclusions we used `+=` rather than `:=` this mean that\nwe want to add one more exclusion to existing default exclusions, Using `:=` would disable default\nexclusions.\n\nYou can use `ijPluginsDir` settings key to see full path to `plugins` subdirectory,\nwhere all jars will be copied. `ijPluginsDir` is intended to be read-only. It can be used,\nfor instance, in `cleanFiles += ijPluginsDir.value`. By default, it is computed from\n`ijPluginsSubDir` and `ijRuntimeSubDir`. You should not reassign it.\n\n### Multi-Module Projects\n\nIf you are using a multi-module projects and would like to include dependent project jars in the plugins directory\nyou need to take extra steps. When a SBT creates a classpath from dependent projects it exports a directory containing its\nresources and compiled class files, but not the actual jar produced by that project.\nIf instead you want to export packaged jars, you need to use SBT option:\n\n```scala\nexportsJars := true\n```\n\nThis is a standard [SBT option](http://www.scala-sbt.org/0.13.0/docs/Howto/package.html).\nYou need to add `exportsJars := true` to every dependent projects in your build.\n(I know it looks tedious, if there is a better solution please let me know).\n\n\nExample Project\n---------------\n\nYou can find example project in sub-directory [example]. \nIt contains a simple project with with two ImageJ plugins.\n\n\nTips and Tricks\n---------------\n\n### Extend `clean` to remove content created by `ijRun` or `ijPrepareRun`\n\nYou can make the regular `clean` command to remove extra content by adding directory to SBT setting `cleanFiles`\n\n```scala\ncleanFiles += ijPluginsDir.value\n```\n\n### Copy additional files to plugins directory when `ijPrepareRun` is executed\n\nSometimes you want to copy some extra files to plugins directory.\nYou can extend `ijPrepareRun` to do the copy or any other tasks:\n\n```scala\nijPrepareRun := ijPrepareRun.value ++ {\n  // Files you want to copy\n  val srcFiles = Seq(\n    new java.io.File(\"file1\"),\n    new java.io.File(\"file2\"),\n    )\n  val destDir = ijPluginsDir.value\n  val destFiles = srcFiles.map(f =\u003e destDir / f.getName)\n  srcFiles zip destFiles.foreach{ case (src, dest) =\u003e IO.copyFile(src, dest) }\n  // The last statement here should return the collection of copied files\n  destFiles\n}\n```\n\n### Running using SBT\n\n1. Open command prompt\n2. Change directory to one containing this project\n3. Execute command `sbt ijRun`\n\n### Running SBT tasks at part of IntelliJ IDEA build\n\n[IntelliJ IDEA](https://www.jetbrains.com/idea/), with Scala plugin, can directly load SBT projects.\nYou can then execute sbt tasks to build and copy needed jars to run your plugins in ImageJ.\n\n#### Option 1: Run `ijRun` task as \"Run Configuration\"\n\n1. From the menu select \"Run\" \u003e \"Edit Configurations...\"\n2. Click `+` (add new configuration) and select \"sbt Task\" as configuration type\n3. Give the configuration a name, say \"ImageJ\"\n4. Under \"Tasks\" type `ijRun`\n5. Make sure that working directory points to your module directory\n\nNow you have new run configuration that will build your code, package jars, and start ImageJ with your plugins.\n\nThe downside of this method is that IntelliJ will not let you debug you code if you start it this way.\n\n#### Option 2: Add `ijPrepareRun` to a typical application run configuration\n\nThe idea is to create a regular application run configuration and execute `sbt ijPrepareRun` to setup runtime directories:\n\n1. From the menu select \"Run\" \u003e \"Edit Configurations...\"\n2. Click `+` (add new configuration) and select \"Application\" as configuration type\n3. Give you configuration a name, say \"ImageJ\"\n4. In \"Main class:\" type `ij.ImageJ`\n5. In \"Working directory:\" select subdirectory \"sandbox\" of your module directory (or a directory you defined in `ijRuntimeSubDir`)\n6. Select relevant project module.\n7. In \"Before lunch:\" select `+` and then select \"Run External Tool\"\n8. In \"External Tool\" window select `+` to define how to execute `sbt ijPrepareRun`\n9. Give the external toll configuration some name.\n10. In \"Program:\" type `sbt`\n11. In \"Arguments:\" type `ijPrepareRun`\n12. In \"Working directory:\" select your module directory\n13. Click \"OK\" a couple of times to close dialogs\n\nNow 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.\n\nLicense\n-------\n\nCopyright (c) 2013-2018 Jarek Sacha\n\nPublished under GPLv3, see LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpsacha%2Fsbt-imagej","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpsacha%2Fsbt-imagej","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpsacha%2Fsbt-imagej/lists"}