developing plugins for xnat 1.8

155 views
Skip to first unread message

angel.m...@gmail.com

unread,
Jul 15, 2021, 11:05:22 PM7/15/21
to xnat_discussion
Hi I'm going to need to develop plugins for our xnat 1.8 instances. I've looked around and so far I can only find templates relevant to xnat 1.7. If I go ahead and build this it does seem to work when I deploy to an xnat 1.8 instance. Are there likely to be any issues with my continuing to do this?

I thought it would be pretty straight forward to modify the gradle files to build for version 1.8 but I've had no success with that. For example if I modify the build file so that it uses xnat 1.8.1, change it to using java 1.8 and comment out the part that is there to ensure compatibility with java 1.7 then it fails on the compile step. Here is a link to the build scan output 

Any ideas of further changes I should make to get the plugin to build for 1.8? 

thanks
Angel

angel.m...@gmail.com

unread,
Jul 15, 2021, 11:08:03 PM7/15/21
to xnat_discussion
I haven't been able to attach the gradle build file and the successfully post so I'm echoing it below instead...

/*
 * xnat-template: build.gradle
 * Copyright (c) 2020, Washington University School of Medicine
 * All Rights Reserved
 *
 * Released under the Simplified BSD.
 */

import org.gradle.internal.jvm.Jvm

// TODO: This block is required for the "xnat-data-builder" plugin to function.
buildscript {
    ext {
        vXnat = "1.8.1"
    }
    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath "org.nrg.xnat.build:xnat-data-builder:${vXnat}"
        classpath "io.franzbecker:gradle-lombok:3.2.0"
        classpath "io.spring.gradle:dependency-management-plugin:1.0.8.RELEASE"
    }
}

// TODO: Change the group and version to values appropriate for your plugin project.
// NOTE: You should not leave the group value set to "org.nrg.xnatx.plugins"! Use
//       something to indicate who developed the plugin and follow the standard
//       For example, if a group at Miskatonic University developed a plugin, the
//       group might be "edu.miskatonic.imaging.xnat".
group "org.nrg.xnatx.plugins"
version vXnat

// TODO: This is the minimum set of Gradle plugins required to build most XNAT plugins. You may include many others, including plugins for testing and test coverage, IDE integration, and more.
apply plugin: "java"
apply plugin: "xnat-data-builder"
apply plugin: "io.franzbecker.gradle-lombok"
apply plugin: "io.spring.dependency-management"

// TODO: This provides access to all of these repositories for dependency resolution.
repositories {
    mavenLocal()
    maven { url "https://www.dcm4che.org/maven2" }
    jcenter()
    mavenCentral()
}

// TODO: As of the 1.7.x release, XNAT is built as a Java 7-compatible (i.e. JDK 1.7) application. All plugins must be 1.7 compatible as well.
sourceCompatibility = 1.8
targetCompatibility = 1.8

// TODO: This defines a dependency package, specifically the XNAT NRG parent pom, which specifies
//       versions for all of XNAT's dependencies. This helps ensure that plugins are building
//       against the same versions of various libraries as XNAT itself.
dependencyManagement.imports {
    mavenBom "org.nrg:parent:${vXnat}"
}

// TODO: This is a pretty minimal set of dependencies, so don't worry if you need to add more.
dependencies {
    implementation "org.nrg.xnat:web"
    implementation "org.nrg.xnat:xnat-data-models"
    implementation "org.nrg.xdat:core"
    implementation "io.springfox:springfox-swagger2"
    implementation "io.springfox:springfox-swagger-ui"
}

lombok {
    version = dependencyManagement.importedProperties["lombok.version"] as String
    sha256 = dependencyManagement.importedProperties["lombok.checksum"] as String
}

// TODO: If the compiler is Java 8 or later, this checks for a Java 7 version of the primary Java run-time library. Building with post-Java 7 libraries can result in occasional compatibility issues.
//def javaVersion = Jvm.current().javaVersion
//if (javaVersion.java8Compatible || javaVersion.java9Compatible) {
//    if (hasProperty("rt.17.jar")) {
        // Solution for bootstrap classpath warning and possible issues with compatibility with 1.7 libraries
        // was taken from this post on discuss.gradle.org: http://bit.ly/24xD9j0
//        def rt17jar = property "rt.17.jar"
//        logger.info "Using ${rt17jar} as the bootstrap class path jar."
//        gradle.projectsEvaluated {
//            tasks.withType(JavaCompile) {
//                options.fork = true
//                options.compilerArgs << "-XDignore.symbol.file"
//                options.bootstrapClasspath = files(rt17jar as String)
//            }
//        }
//    } else {
//        logger.warn "No value was set for the rt.17.jar build property, using the default bootstrap class path. You should consider setting rt.17.jar to indicate a jar file containing the Java 1.7 run-time library:\n"
//        logger.warn "  ./gradlew -Prt.17.jar=rt-1.7.0_45.jar war\n"
//    }
//}

// TODO: This tells the compiler where to find source code. This isn't required in a standard build, but the XNAT data builder generates code from XNAT data-type schemas that the compiler needs to know about.
sourceSets {
    main {
        java {
            srcDir "src/main/java"
            srcDir "build/xnat-generated/src/main/java"
        }
        resources {
            srcDir "src/main/resources"
            srcDir "build/xnat-generated/src/main/resources"
        }
    }
}


dev

unread,
Jul 16, 2021, 9:23:45 AM7/16/21
to xnat_discussion
Hello,

I would recommand to :
- In the new folder, generate the jar with ./gradlew clean build (see more info in the readme.md)
- copy the jar in the /data/xnat/home/plugin folder (see README.md for more details)
- restart xnat-web container
- Ensure there is no exception with docker-compose logs xnat-web, or any file in the /data/xnat/home/logs folder

More specifically, this build.gradle is now at the version 1.8.2 :

Herrick, Rick

unread,
Jul 16, 2021, 4:36:46 PM7/16/21
to xnat_di...@googlegroups.com

Hi Angel,

 

Try updating the repository again:

 

g...@bitbucket.org:xnatx/xnat-template-plugin.git

 

I just merged the latest code from our develop branch to master. This builds and works with XNAT 1.8.2.

 

-- 

Rick Herrick

XNAT Architect/Developer

Computational Imaging Laboratory

Washington University School of Medicine

 

 

From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of angel.m...@gmail.com <angel.m...@gmail.com>
Date: Thursday, July 15, 2021 at 10:05 PM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: [XNAT Discussion] developing plugins for xnat 1.8

* External Email - Caution *

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/5bc10125-b410-4a48-abd3-e4fc882effc9n%40googlegroups.com.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

Angel Kennedy

unread,
Jul 21, 2021, 11:49:40 PM7/21/21
to xnat_di...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages