Skip to content
Giuseppe Barbieri edited this page Mar 18, 2021 · 5 revisions

- How do I import a SciJava gradle project (i.e.scenery) into IntelliJ? Do I need plugins / specific settings?

No, you don't need any plugin or specific setting

gif

- Which JDK do I chose for scenery / sciview?

Whatever you want

How do I run tests for my SciJava gradle project locally?

gif

How do I update the pom-scijava version in a SciJava gradle project?

This is not yet possible, it's a work in progress

How do I make a maven project (i.e. sciview) use my local gradle project (i.e. scenery) instead of the one defined in the pom.xml file?

How do I get maven to refer to the local version of a Gradle project (scenery)? Previously, this was possible because maven would first refer to the local maven repository when searching for a dependency. To be clear, this relates to using maven from the command-line, not through IntelliJ

I guess it's not possible, you could use mavenLocal though

How do I add sciview to the same project scenery is in? (File > New > Module from existing sources..)

How do I make a gradle project use another local gradle project (i.e. once scenery is ported to gradle) instead of the one specified in the gradle dependencies?

You don't, scenery is a sciview dependency, so ideally you'd like to add scenery in the same window as sciview in order to modify it and see the changes apply downstream immediately, without any publication in between.

This is called Composite Build in Gradle terms, official docs

Note: in order for this to work, you must use the graphics.scenery group for the corresponding binary dependency (instead the default jitpack one, that is com.github.scenery, Ulrik set a DNS remapping for that, so don't worry). This is necessary because for Gradle to perform automatically the substitution underneath the GAV (Group:Artifact:Version) must correspond (actually only GA).

gif

How do I release a new version of my gradle project (scenery) to the SciJava maven server? (= previously running the release.sh script)

  1. Setup
  • you better have gradle install globally, for Linux you can also use snap
  • save your credential (official docs) in your ~/.gradle/gradle.properties as ${name}Username and ${name}Password, let's use name = scijava, then we will have to add the following
scijavaUsername=myNick
scijavaPassword=myPass
  • apply the maven publish plugin
plugins {
    ...
    `maven-publish`
}
  • specify the settings
publishing {
    repositories {
        maven {
            name = "scijava" // this is the key used by Gradle to look for the credentials you save in your ~/.gradle/gradle.properties
            credentials(PasswordCredentials::class)
            url = uri("myScijavaRepo")
    }
}

using a programming language to define the build shines particularly in this case, the power is in your hand, for example you may want to add some logic to detect if this publication is going to be a release or a snapshot and react consequently

            url = uri(when {
                "SNAPSHOT" in rootProject.version -> "mySnapshotRepo"
                else -> "myReleaseRepo"
            })
  1. Deploy
  • bump the version as wished (for scenery it's in the setting.gradle.kts)
  • execute publish task

Does copying of Gradle-based dependencies (scenery) work the same way as maven-based dependencies, for a maven project (scenery-insitu or sciview)? When scenery was maven based, this was achievable by running mvn install dependency:copy-dependencies or by creating a fat-jar

  1. copy-dependencies

add the following in your build.gradle.kts

task("copy-dependencies", Copy::class) {
    from(configurations.default).into("$buildDir/deps")
}
  1. fat jar

apply the shadow plugin

plugins {
  id "com.github.johnrengelman.shadow" version "6.1.0"
}

and use task shadowJar to generate the fat jar

Clone this wiki locally