Skip to content

Commit

Permalink
Merge pull request #167 from CRESS-Surrey/6.4.0_update
Browse files Browse the repository at this point in the history
Update the extension to work with NetLogo 6.4.0
  • Loading branch information
nicolaspayette authored Dec 10, 2023
2 parents 83865eb + 70b8dd0 commit 4b8bb27
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 266 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*.class
*.log
*.jar
xw.zip
xw-*.zip
xw/.bundledFiles

# sbt specific
.history
Expand All @@ -21,3 +22,7 @@ project/plugins/project/
.cache
.settings
.cache-main

# IntelliJ Idea
.idea
.bsp
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ An extension for creating additional interface tabs in the [NetLogo](https://git

### Installing

To install the eXtraWidgets extension, assuming that you already have [NetLogo 6.0.0-BETA1 or later](https://ccl.northwestern.edu/netlogo/download.shtml) installed, [**download** the extension](https://github.com/CRESS-Surrey/eXtraWidgets/releases/latest) and unzip it NetLogo's `extensions/` folder, like you would for any other [NetLogo extension](http://ccl.northwestern.edu/netlogo/docs/extensions.html).
To install the eXtraWidgets extension, assuming that you already have [NetLogo 6.4](https://ccl.northwestern.edu/netlogo/download.shtml) installed, [**download** the extension](https://github.com/CRESS-Surrey/eXtraWidgets/releases/latest) and unzip it NetLogo's `extensions/` folder, like you would for any other [NetLogo extension](http://ccl.northwestern.edu/netlogo/docs/extensions.html).

(For use with the 5.x series of NetLogo, you need [eXtraWidgets 1.1.0](https://github.com/CRESS-Surrey/eXtraWidgets/releases/tag/v1.1.0).)

Expand Down
20 changes: 7 additions & 13 deletions api/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "eXtraWidgets-API"

scalaVersion := "2.12.2"
scalaVersion := "2.12.18"

scalacOptions ++= Seq(
"-feature",
Expand All @@ -11,20 +11,14 @@ scalacOptions ++= Seq(

exportJars := true

artifactName in Compile := { (_, _, artifact: Artifact) => artifact.name + "." + artifact.extension }
Compile / artifactName := { (_, _, artifact: Artifact) => artifact.name + "." + artifact.extension }

artifactName in Test := { (_, _, artifact: Artifact) => artifact.name + "-test." + artifact.extension }
Test / artifactName := { (_, _, artifact: Artifact) => artifact.name + "-test." + artifact.extension }

resolvers += Resolver.bintrayRepo("netlogo", "NetLogo-JVM")
resolvers += "netlogo" at "https://dl.cloudsmith.io/public/netlogo/netlogo/maven/"

libraryDependencies ++= Seq(
"org.nlogo" % "netlogo" % "6.0.4" intransitive
"org.nlogo" % "netlogo" % "6.4.0",
"org.jogamp.jogl" % "jogl-all" % "2.4.0" from "https://jogamp.org/deployment/v2.4.0/jar/jogl-all.jar",
"org.jogamp.gluegen" % "gluegen-rt" % "2.4.0" from "https://jogamp.org/deployment/v2.4.0/jar/gluegen-rt.jar"
)

site.settings

site.includeScaladoc("/")

ghpages.settings

git.remoteRepo := "git@github.com:CRESS-Surrey/eXtraWidgets.git"
1 change: 1 addition & 0 deletions api/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.5.5
2 changes: 1 addition & 1 deletion api/src/main/scala/uk/ac/surrey/xw/api/Tab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class Tab(
}

def removeFromAppTabs(): Unit = {
tabs.removeMenuItem(index)
tabs.remove(this)
tabs.updateTabsMenu()
}

}
49 changes: 17 additions & 32 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,55 +1,40 @@
ThisBuild / version := "2.0.0"
ThisBuild / scalaVersion := "2.12.18"
ThisBuild / scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-Xfatal-warnings",
"-encoding", "UTF8")

lazy val root = (project in file("."))
.settings(version := "2.0.0")
.aggregate(xw, core, api, note, checkbox, slider, chooser, multichooser, input, button)
.aggregate(api, core, note, checkbox, slider, chooser, multichooser, input, button, xw)

lazy val api = project
.settings(version := "2.0.0")

lazy val core = project
.settings(version := "2.0.0")
.dependsOn(api)

lazy val note = (project in file("./xw/widgets/NoteWidget/"))
.settings(version := "2.0.0")
.dependsOn(api)

lazy val checkbox = (project in file("./xw/widgets/CheckboxWidget/"))
.settings(version := "2.0.0")
.dependsOn(api)

lazy val slider = (project in file("./xw/widgets/SliderWidget/"))
.settings(version := "2.0.0")
.dependsOn(api)

lazy val chooser = (project in file("./xw/widgets/ChooserWidget/"))
.settings(version := "2.0.0")
.dependsOn(api)

lazy val multichooser = (project in file("./xw/widgets/MultiChooserWidget/"))
.settings(version := "2.0.0")
.dependsOn(api)

lazy val input = (project in file("./xw/widgets/InputWidgets/"))
.settings(version := "2.0.0")
.dependsOn(api)

lazy val button = (project in file("./xw/widgets/ButtonWidget/"))
.settings(version := "2.0.0")
.dependsOn(api)

lazy val xw = project.dependsOn(core)
.settings(
version := "2.0.0",
(test in Test) := {
val _ = Seq(
(Keys.`package` in (note, Compile)).value,
(Keys.`package` in (checkbox, Compile)).value,
(Keys.`package` in (slider, Compile)).value,
(Keys.`package` in (chooser, Compile)).value,
(Keys.`package` in (multichooser, Compile)).value,
(Keys.`package` in (input, Compile)).value,
(Keys.`package` in (button, Compile)).value
)
(test in Test).value
}
)
.dependsOn(api)

lazy val core = project
.dependsOn(api)

lazy val xw = project
.dependsOn(core)
6 changes: 3 additions & 3 deletions core/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "eXtraWidgets-Core"

scalaVersion := "2.12.0"
scalaVersion := "2.12.18"

scalacOptions ++= Seq(
"-feature",
Expand All @@ -11,9 +11,9 @@ scalacOptions ++= Seq(

exportJars := true

artifactName in Compile := { (_, _, artifact: Artifact) => artifact.name + "." + artifact.extension }
Compile / artifactName := { (_, _, artifact: Artifact) => artifact.name + "." + artifact.extension }

artifactName in Test := { (_, _, artifact: Artifact) => artifact.name + "-test." + artifact.extension }
Test / artifactName := { (_, _, artifact: Artifact) => artifact.name + "-test." + artifact.extension }

fork := true

Expand Down
1 change: 1 addition & 0 deletions core/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.5.5
7 changes: 6 additions & 1 deletion core/src/main/scala/uk/ac/surrey/xw/WidgetsLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ object WidgetsLoader {
modifiers = clazz.getModifiers
if isPublic(modifiers) && !isAbstract(modifiers) &&
classOf[WidgetKind[_]].isAssignableFrom(clazz)
} yield clazz.newInstance.asInstanceOf[WidgetKind[_ <: ExtraWidget]]
} yield {
clazz
.getDeclaredConstructor(Seq.empty[Class[_]] : _*)
.newInstance()
.asInstanceOf[WidgetKind[_ <: ExtraWidget]]
}
(new TabKind +: widgetKinds)
.map(kind kind.name -> kind)
.toMap
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.12
sbt.version=1.5.5
9 changes: 2 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4")
resolvers += "netlogo-extension-plugin" at "https://dl.cloudsmith.io/public/netlogo/netlogo-extension-plugin/maven/"

resolvers += Resolver.url(
"NetLogo-JVM",
url("http://dl.bintray.com/content/netlogo/NetLogo-JVM"))(
Resolver.ivyStylePatterns)

addSbtPlugin("org.nlogo" % "netlogo-extension-plugin" % "3.0")
addSbtPlugin("org.nlogo" % "netlogo-extension-plugin" % "5.2.3")
87 changes: 21 additions & 66 deletions xw/build.sbt
Original file line number Diff line number Diff line change
@@ -1,68 +1,23 @@
scalaVersion := "2.12.2"

enablePlugins(org.nlogo.build.NetLogoExtension)

scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-Xfatal-warnings",
"-encoding", "UTF8")

name := "eXtraWidgets-Extension"

netLogoExtName := "xw"

netLogoClassManager := "uk.ac.surrey.xw.extension.ExtraWidgetsExtension"

netLogoZipSources := false

netLogoTarget :=
org.nlogo.build.NetLogoExtension.directoryTarget(baseDirectory.value)

netLogoVersion := "6.0.4"

libraryDependencies ++= Seq(
"org.ow2.asm" % "asm-all" % "5.0.4" % "test",
"org.picocontainer" % "picocontainer" % "2.13.6" % "test",
"org.scalatest" %% "scalatest" % "3.0.0" % "test",
"commons-codec" % "commons-codec" % "1.10" % "test"
)

test in Test := {
val _ = (packageBin in Compile).value
(test in Test).value
}

val jarName = "xw.jar"

packageBin in Compile <<= (packageBin in Compile, baseDirectory, dependencyClasspath in Runtime) map {
(jar, base, classPath) =>
IO.copyFile(jar, base / jarName)
val jarFiles = classPath.files
.filter { _.getName matches "(.*).jar" }
.filterNot { _.getName matches "netlogo(.*).jar" }
.filterNot { _.getName matches "scala-library(.*).jar" }
jarFiles.foreach(file => IO.copyFile(file, base / file.getName))
// copy everything thing we need for distribution in a
// temp "xw" directory, which we will zip before deleting it.
IO.createDirectory(base / "xw")
val fileNames = jarFiles.map(_.getName) :+ "xw.jar"
for (fn <- fileNames) IO.copyFile(base / fn, base / "xw" / fn)
IO.createDirectory(base / "xw" / "widgets")
for {
path <- (base / "widgets").listFiles
if path.isDirectory
file <- path.listFiles
if file.getName.endsWith(".jar")
} {
IO.createDirectory(base / "xw" / "widgets" / path.getName)
IO.copyFile(file, base / "xw" / "widgets" / path.getName / file.getName)
}
IO.delete(base / "xw.zip")
Process(Seq("zip", "-r", "xw.zip", "xw"), base).!!
IO.delete(base / "xw")
jar
}

cleanFiles <++= baseDirectory { base => Seq(base / jarName) }
name := "eXtraWidgets Extension"
netLogoExtName := "xw"
netLogoClassManager := "uk.ac.surrey.xw.extension.ExtraWidgetsExtension"
netLogoVersion := "6.4.0"
netLogoShortDescription := "An extension for creating additional interface tabs in the NetLogo GUI and putting custom widgets on them."
netLogoLongDescription := netLogoShortDescription.value
netLogoHomepage := "https://github.com/NetLogo/NetLogo-Extension-Plugin"

netLogoPackageExtras ++=
Seq("api", "core")
.map(x =>
(baseDirectory.value / ".." / x / "target" / "scala-2.12" / s"extrawidgets-$x.jar", None)
) ++
(baseDirectory.value / "widgets")
.listFiles
.filter(_.isDirectory)
.map(widgetFolder => {
val name = widgetFolder.getName
val jar = widgetFolder / "target" / "scala-2.12" / (name + ".jar")
(jar, Option("widgets/" + name + "/" + jar.getName))
})
21 changes: 1 addition & 20 deletions xw/widgets/ButtonWidget/build.sbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
name := "ButtonWidget"

scalaVersion := "2.12.2"

scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-Xfatal-warnings",
"-encoding", "UTF8")

val jarName = "ButtonWidget.jar"

artifactName := { (_, _, _) => jarName }

packageBin in Compile <<= (packageBin in Compile, baseDirectory) map {
(jar, base) =>
IO.copyFile(jar, base / jarName)
jar
}

cleanFiles <++= baseDirectory { base => Seq(base / jarName) }
artifactName := { (_, _, _) => name.value + ".jar" }
21 changes: 1 addition & 20 deletions xw/widgets/CheckboxWidget/build.sbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
name := "CheckboxWidget"

scalaVersion := "2.12.2"

scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-Xfatal-warnings",
"-encoding", "UTF8")

val jarName = "CheckboxWidget.jar"

artifactName := { (_, _, _) => jarName }

packageBin in Compile <<= (packageBin in Compile, baseDirectory) map {
(jar, base) =>
IO.copyFile(jar, base / jarName)
jar
}

cleanFiles <++= baseDirectory { base => Seq(base / jarName) }
artifactName := { (_, _, _) => name.value + ".jar" }
21 changes: 1 addition & 20 deletions xw/widgets/ChooserWidget/build.sbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
name := "ChooserWidget"

scalaVersion := "2.12.2"

scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-Xfatal-warnings",
"-encoding", "UTF8")

val jarName = "ChooserWidget.jar"

artifactName := { (_, _, _) => jarName }

packageBin in Compile <<= (packageBin in Compile, baseDirectory) map {
(jar, base) =>
IO.copyFile(jar, base / jarName)
jar
}

cleanFiles <++= baseDirectory { base => Seq(base / jarName) }
artifactName := { (_, _, _) => name.value + ".jar" }
21 changes: 1 addition & 20 deletions xw/widgets/InputWidgets/build.sbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
name := "InputWidgets"

scalaVersion := "2.12.2"

scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-Xfatal-warnings",
"-encoding", "UTF8")

val jarName = "InputWidgets.jar"

artifactName := { (_, _, _) => jarName }

packageBin in Compile <<= (packageBin in Compile, baseDirectory) map {
(jar, base) =>
IO.copyFile(jar, base / jarName)
jar
}

cleanFiles <++= baseDirectory { base => Seq(base / jarName) }
artifactName := { (_, _, _) => name.value + ".jar" }
Loading

0 comments on commit 4b8bb27

Please sign in to comment.