diff --git a/Makefile b/Makefile index 4d140c6..25d004c 100644 --- a/Makefile +++ b/Makefile @@ -1,71 +1,21 @@ -config ?= compileClasspath - -ifdef module -mm = :${module}: -else -mm = -endif +# Build the plugin +assemble: + ./gradlew assemble clean: rm -rf .nextflow* rm -rf work rm -rf build - rm -rf plugins/*/build ./gradlew clean -compile: - ./gradlew compileGroovy - @echo "DONE `date`" - - -check: - ./gradlew check - - -# -# Show dependencies try `make deps config=runtime`, `make deps config=google` -# -deps: - ./gradlew -q ${mm}dependencies --configuration ${config} - -deps-all: - ./gradlew -q dependencyInsight --configuration ${config} --dependency ${module} - -# -# Refresh SNAPSHOTs dependencies -# -refresh: - ./gradlew --refresh-dependencies - -# -# Run all tests or selected ones -# +# Run plugin unit tests test: -ifndef class - ./gradlew ${mm}test -else - ./gradlew ${mm}test --tests ${class} -endif - -assemble: - ./gradlew assemble - -# -# generate build zips under build/plugins -# you can install the plugin copying manually these files to $HOME/.nextflow/plugins -# -buildPlugins: - ./gradlew copyPluginZip - -# -# Upload JAR artifacts to Maven Central -# -upload: - ./gradlew upload - + ./gradlew test -upload-plugins: - ./gradlew plugins:upload +# Install the plugin into local nextflow plugins dir +install: + ./gradlew install -publish-index: - ./gradlew plugins:publishIndex +# Publish the plugin +release: + ./gradlew releasePlugin \ No newline at end of file diff --git a/plugins/nf-sqldb/build.gradle b/build.gradle similarity index 56% rename from plugins/nf-sqldb/build.gradle rename to build.gradle index db7d9c5..eb53630 100644 --- a/plugins/nf-sqldb/build.gradle +++ b/build.gradle @@ -14,19 +14,34 @@ * limitations under the License. */ -plugins { - // Apply the groovy plugin to add support for Groovy - id 'io.nextflow.groovy-library-conventions' - id 'idea' - id 'de.undercouch.download' version '4.1.2' +// Add the download plugin +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'de.undercouch:gradle-download-task:4.1.2' + } } -group = 'io.nextflow' -// DO NOT SET THE VERSION HERE -// THE VERSION FOR PLUGINS IS DEFINED IN THE `/resources/META-INF/MANIFEST.NF` file +plugins { + id 'io.nextflow.nextflow-plugin' version '0.0.1-alpha' +} -idea { - module.inheritOutputDirs = true +sourceSets { + main { + groovy { + srcDirs = ['src/main/groovy'] + } + resources { + srcDirs = ['src/main/resources'] + } + } + test { + groovy { + srcDirs = ['src/test/groovy'] + } + } } repositories { @@ -36,29 +51,8 @@ repositories { maven { url = 'https://s3-eu-west-1.amazonaws.com/maven.seqera.io/snapshots' } } -configurations { - // see https://docs.gradle.org/4.1/userguide/dependency_management.html#sub:exclude_transitive_dependencies - runtimeClasspath.exclude group: 'org.slf4j', module: 'slf4j-api' -} - -sourceSets { - main.java.srcDirs = [] - main.groovy.srcDirs = ['src/main'] - main.resources.srcDirs = ['src/resources'] - test.groovy.srcDirs = ['src/test'] - test.java.srcDirs = [] - test.resources.srcDirs = [] -} - -ext{ - nextflowVersion = '24.04.0' -} - dependencies { - compileOnly "io.nextflow:nextflow:$nextflowVersion" - compileOnly 'org.slf4j:slf4j-api:2.0.7' - compileOnly 'org.pf4j:pf4j:3.12.0' - + // API dependencies from the original build.gradle api("org.apache.groovy:groovy-sql:4.0.23") { transitive = false } api 'com.h2database:h2:1.4.200' api 'mysql:mysql-connector-java:8.0.33' @@ -66,19 +60,17 @@ dependencies { api 'org.postgresql:postgresql:42.7.4' api 'org.xerial:sqlite-jdbc:3.47.0.0' api 'org.duckdb:duckdb_jdbc:0.10.2' - - - // JDBC driver setup for AWS Athena - the 3rd party JAR are being downloaded and setup as gradle tasks below. - // Reference https://docs.aws.amazon.com/athena/latest/ug/connect-with-jdbc.html + + // Replace commons-logging with jcl-over-slf4j + implementation 'org.slf4j:jcl-over-slf4j:2.0.7' + + // JDBC driver for AWS Athena api files('src/dist/lib/AthenaJDBC42_2.0.25.1001.jar') - - //NOTE: Had to remove the slf4j jar due to a conflict implementation fileTree(dir: 'src/dist/lib/libs', include: '*.jar') - - // test configuration + + // Test dependencies testImplementation "org.apache.groovy:groovy:4.0.23" testImplementation "org.apache.groovy:groovy-nio:4.0.23" - testImplementation "io.nextflow:nextflow:$nextflowVersion" testImplementation ("org.apache.groovy:groovy-test:4.0.23") { exclude group: 'org.apache.groovy' } testImplementation ("cglib:cglib-nodep:3.3.0") testImplementation ("org.objenesis:objenesis:3.1") @@ -86,25 +78,59 @@ dependencies { testImplementation ('org.spockframework:spock-junit4:2.3-groovy-4.0') { exclude group: 'org.apache.groovy'; exclude group: 'net.bytebuddy' } testImplementation ('com.google.jimfs:jimfs:1.1') - testImplementation(testFixtures("io.nextflow:nextflow:$nextflowVersion")) - testImplementation(testFixtures("io.nextflow:nf-commons:$nextflowVersion")) + // Add back Nextflow test dependencies + testImplementation "io.nextflow:nextflow:${nextflowPlugin.nextflowVersion}" + testImplementation(testFixtures("io.nextflow:nextflow:${nextflowPlugin.nextflowVersion}")) + testImplementation(testFixtures("io.nextflow:nf-commons:${nextflowPlugin.nextflowVersion}")) +} + +configurations { + // see https://docs.gradle.org/4.1/userguide/dependency_management.html#sub:exclude_transitive_dependencies + runtimeClasspath.exclude group: 'org.slf4j', module: 'slf4j-api' +} - // see https://docs.gradle.org/4.1/userguide/dependency_management.html#sec:module_replacement - modules { - module("commons-logging:commons-logging") { replacedBy("org.slf4j:jcl-over-slf4j") } +// Use the version from the MANIFEST.MF +version = '0.6.0' + +nextflowPlugin { + // From the MANIFEST.MF + nextflowVersion = '24.04.0' + + provider = 'Seqera Labs' + className = 'nextflow.sql.SqlPlugin' + extensionPoints = [ + 'nextflow.sql.ChannelSqlExtension' + ] + + publishing { + github { + repository = 'seqera/nf-sqldb' + userName = project.findProperty('github_username') + authToken = project.findProperty('github_access_token') + email = project.findProperty('github_commit_email') + + // You may need to adjust this URL if the central plugin index is different + indexUrl = 'https://github.com/nextflow-io/plugins/main/plugins.json' + } } } +// Configure the packagePlugin task to handle duplicates +tasks.named('packagePlugin') { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + +// Add test configuration for Java modules test { useJUnitPlatform() + jvmArgs = ['--add-opens=java.base/java.lang=ALL-UNNAMED', + '--add-opens=java.base/java.util=ALL-UNNAMED', + '--add-opens=java.base/java.lang.reflect=ALL-UNNAMED'] } -/** - * AWS Athena - * The following tasks download and confirm the MD5 checksum of the ZIP archive - * for Simba Athena JDBC driver and extract its contents to the build directory - * Reference: https://docs.aws.amazon.com/athena/latest/ug/connect-with-jdbc.html - */ +// AWS Athena dependencies setup - migrated from the original build.gradle +apply plugin: 'de.undercouch.download' + task downloadAthenDep(type: Download) { src 'https://s3.amazonaws.com/athena-downloads/drivers/JDBC/SimbaAthenaJDBC-2.0.25.1001/SimbaAthenaJDBC-2.0.25.1001.zip' dest new File(buildDir, 'downloads/SimbaAthenaJDBC-2.0.25.1001.zip') @@ -122,11 +148,13 @@ task unzipAthenDep(dependsOn: verifyAthenDep, type: Copy) { into "${buildDir}/downloads/unzip/awsathena/" } -// Files under src/dist are included into the distribution zip -// https://docs.gradle.org/current/userguide/application_plugin.html task copyAthenDep(dependsOn: unzipAthenDep, type: Copy) { from file(new File(buildDir, '/downloads/unzip/awsathena/SimbaAthenaJDBC-2.0.25.1001/AthenaJDBC42_2.0.25.1001.jar')) into "src/dist/lib" } -project.copyPluginLibs.dependsOn('copyAthenDep') -project.compileGroovy.dependsOn('copyAthenDep') + +// Make sure compileGroovy depends on copyAthenDep +compileGroovy.dependsOn(copyAthenDep) + +// Hook into the assemble task to ensure Athena dependencies are properly set up +assemble.dependsOn('copyAthenDep') \ No newline at end of file diff --git a/plugins/build.gradle b/plugins/build.gradle deleted file mode 100644 index ed5a617..0000000 --- a/plugins/build.gradle +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2021-2022, Seqera Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id "java" - id "io.nextflow.nf-build-plugin" version "1.0.1" -} - -ext.github_organization = 'nextflow-io' -ext.github_username = project.findProperty('github_username') ?: 'pditommaso' -ext.github_access_token = project.findProperty('github_access_token') ?: System.getenv('GITHUB_TOKEN') -ext.github_commit_email = project.findProperty('github_commit_email') ?: 'paolo.ditommaso@gmail.com' - -jar.enabled = false - -String computeSha512(File file) { - if( !file.exists() ) - throw new GradleException("Missing file: $file -- cannot compute SHA-512") - return org.apache.commons.codec.digest.DigestUtils.sha512Hex(file.bytes) -} - -String now() { - "${java.time.OffsetDateTime.now().format(java.time.format.DateTimeFormatter.ISO_DATE_TIME)}" -} - -List allPlugins() { - def plugins = [] - new File(rootProject.rootDir, 'plugins') .eachDir { if(it.name.startsWith('nf-')) plugins.add(it.name) } - return plugins -} - -String metaFromManifest(String meta, File file) { - def str = file.text - def regex = ~/(?m)^$meta:\s*([\w-\.<>=]+)$/ - def m = regex.matcher(str) - if( m.find() ) { - def ver = m.group(1) - //println "Set plugin '${file.parentFile.parentFile.parentFile.parentFile.name}' version=${ver}" - return ver - } - throw new GradleException("Cannot find '$meta' for plugin: $file") -} - -def timestamp = now() - -subprojects { - apply plugin: 'java' - apply plugin: 'groovy' - apply plugin: 'io.nextflow.nf-build-plugin' - - repositories { - mavenLocal() - mavenCentral() - } - - version = metaFromManifest('Plugin-Version',file('src/resources/META-INF/MANIFEST.MF')) - - tasks.withType(Jar) { - duplicatesStrategy = DuplicatesStrategy.INCLUDE - } - - /* - * Creates plugin zip and json meta file in plugin `build/libs` directory - */ - task makeZip(type: Jar) { - into('classes') { with jar } - into('lib') { from configurations.runtimeClasspath } - manifest.from file('src/resources/META-INF/MANIFEST.MF') - archiveExtension = 'zip' - preserveFileTimestamps = false - reproducibleFileOrder = true - - doLast { - // create the meta file - final zip = new File("$buildDir/libs/${project.name}-${project.version}.zip") - final json = new File("$buildDir/libs/${project.name}-${project.version}-meta.json") - json.text = """\ - { - "version": "${project.version}", - "date": "${timestamp}", - "url": "https://github.com/${github_organization}/${project.name}/releases/download/${project.version}/${project.name}-${project.version}.zip", - "requires": "${metaFromManifest('Plugin-Requires',file('src/resources/META-INF/MANIFEST.MF'))}", - "sha512sum": "${computeSha512(zip)}" - } - """.stripIndent() - // cleanup tmp dir - file("$buildDir/tmp/makeZip").deleteDir() - } - outputs.file("$buildDir/libs/${project.name}-${project.version}.zip") - } - - /* - * Copy the plugin dependencies in the subproject `build/target/libs` directory - */ - task copyPluginLibs(type: Sync) { - from configurations.runtimeClasspath - into 'build/target/libs' - } - - /* - * Copy the plugin in the project root build/plugins directory - */ - task copyPluginZip(type: Copy, dependsOn: project.tasks.findByName('makeZip')) { - from makeZip - into "$rootProject.buildDir/plugins" - outputs.file("$rootProject.buildDir/plugins/${project.name}-${project.version}.zip") - doLast { - ant.unzip( - src: "$rootProject.buildDir/plugins/${project.name}-${project.version}.zip", - dest: "$rootProject.buildDir/plugins/${project.name}-${project.version}" - ) - } - } - - /* - * "install" the plugin the project root build/plugins directory - */ - project.parent.tasks.getByName("assemble").dependsOn << copyPluginZip - - task uploadPlugin(type: io.nextflow.gradle.tasks.GithubUploader, dependsOn: makeZip) { - assets = providers.provider {["$buildDir/libs/${project.name}-${project.version}.zip", - "$buildDir/libs/${project.name}-${project.version}-meta.json" ]} - release = providers.provider { project.version } - repo = providers.provider { project.name } - owner = github_organization - userName = github_username - authToken = github_access_token - skipExisting = true - } - - jar { - from sourceSets.main.allSource - doLast { - file("$buildDir/tmp/jar").deleteDir() - } - } - - tasks.withType(GenerateModuleMetadata) { - enabled = false - } - - task upload(dependsOn: [uploadPlugin] ) { } -} - -/* - * Upload all plugins to the corresponding GitHub repos - */ -task upload(dependsOn: [subprojects.uploadPlugin]) { } - -/* - * Copies the plugins required dependencies in the corresponding lib directory - */ -classes.dependsOn subprojects.copyPluginLibs - -/* - * Merge and publish the plugins index file - */ -task publishIndex( type: io.nextflow.gradle.tasks.GithubRepositoryPublisher ) { - indexUrl = 'https://github.com/nextflow-io/plugins/main/plugins.json' - repos = allPlugins() - owner = github_organization - githubUser = github_username - githubEmail = github_commit_email - githubToken = github_access_token -} diff --git a/settings.gradle b/settings.gradle index 818b0df..8e86890 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,11 @@ +// For the Nextflow plugin Gradle plugin +pluginManagement { + repositories { + mavenLocal() + gradlePluginPortal() + } +} + /* * Copyright 2021, Seqera Labs * @@ -21,6 +29,4 @@ plugins { } rootProject.name = 'nf-sqldb' -include 'plugins' -include('plugins:nf-sqldb') diff --git a/plugins/nf-sqldb/src/main/nextflow/sql/ChannelSqlExtension.groovy b/src/main/groovy/nextflow/sql/ChannelSqlExtension.groovy similarity index 100% rename from plugins/nf-sqldb/src/main/nextflow/sql/ChannelSqlExtension.groovy rename to src/main/groovy/nextflow/sql/ChannelSqlExtension.groovy diff --git a/plugins/nf-sqldb/src/main/nextflow/sql/InsertHandler.groovy b/src/main/groovy/nextflow/sql/InsertHandler.groovy similarity index 100% rename from plugins/nf-sqldb/src/main/nextflow/sql/InsertHandler.groovy rename to src/main/groovy/nextflow/sql/InsertHandler.groovy diff --git a/plugins/nf-sqldb/src/main/nextflow/sql/QueryHandler.groovy b/src/main/groovy/nextflow/sql/QueryHandler.groovy similarity index 100% rename from plugins/nf-sqldb/src/main/nextflow/sql/QueryHandler.groovy rename to src/main/groovy/nextflow/sql/QueryHandler.groovy diff --git a/plugins/nf-sqldb/src/main/nextflow/sql/QueryOp.groovy b/src/main/groovy/nextflow/sql/QueryOp.groovy similarity index 100% rename from plugins/nf-sqldb/src/main/nextflow/sql/QueryOp.groovy rename to src/main/groovy/nextflow/sql/QueryOp.groovy diff --git a/plugins/nf-sqldb/src/main/nextflow/sql/SqlPlugin.groovy b/src/main/groovy/nextflow/sql/SqlPlugin.groovy similarity index 100% rename from plugins/nf-sqldb/src/main/nextflow/sql/SqlPlugin.groovy rename to src/main/groovy/nextflow/sql/SqlPlugin.groovy diff --git a/plugins/nf-sqldb/src/main/nextflow/sql/config/DriverRegistry.groovy b/src/main/groovy/nextflow/sql/config/DriverRegistry.groovy similarity index 100% rename from plugins/nf-sqldb/src/main/nextflow/sql/config/DriverRegistry.groovy rename to src/main/groovy/nextflow/sql/config/DriverRegistry.groovy diff --git a/plugins/nf-sqldb/src/main/nextflow/sql/config/SqlConfig.groovy b/src/main/groovy/nextflow/sql/config/SqlConfig.groovy similarity index 100% rename from plugins/nf-sqldb/src/main/nextflow/sql/config/SqlConfig.groovy rename to src/main/groovy/nextflow/sql/config/SqlConfig.groovy diff --git a/plugins/nf-sqldb/src/main/nextflow/sql/config/SqlDataSource.groovy b/src/main/groovy/nextflow/sql/config/SqlDataSource.groovy similarity index 100% rename from plugins/nf-sqldb/src/main/nextflow/sql/config/SqlDataSource.groovy rename to src/main/groovy/nextflow/sql/config/SqlDataSource.groovy diff --git a/plugins/nf-sqldb/src/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF similarity index 100% rename from plugins/nf-sqldb/src/resources/META-INF/MANIFEST.MF rename to src/main/resources/META-INF/MANIFEST.MF diff --git a/plugins/nf-sqldb/src/resources/META-INF/extensions.idx b/src/main/resources/META-INF/extensions.idx similarity index 100% rename from plugins/nf-sqldb/src/resources/META-INF/extensions.idx rename to src/main/resources/META-INF/extensions.idx diff --git a/plugins/nf-sqldb/src/test/nextflow/sql/ChannelSqlExtensionTest.groovy b/src/test/groovy/nextflow/sql/ChannelSqlExtensionTest.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/nextflow/sql/ChannelSqlExtensionTest.groovy rename to src/test/groovy/nextflow/sql/ChannelSqlExtensionTest.groovy diff --git a/plugins/nf-sqldb/src/test/nextflow/sql/InsertHandlerTest.groovy b/src/test/groovy/nextflow/sql/InsertHandlerTest.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/nextflow/sql/InsertHandlerTest.groovy rename to src/test/groovy/nextflow/sql/InsertHandlerTest.groovy diff --git a/plugins/nf-sqldb/src/test/nextflow/sql/QueryHandlerTest.groovy b/src/test/groovy/nextflow/sql/QueryHandlerTest.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/nextflow/sql/QueryHandlerTest.groovy rename to src/test/groovy/nextflow/sql/QueryHandlerTest.groovy diff --git a/plugins/nf-sqldb/src/test/nextflow/sql/SqlDslTest.groovy b/src/test/groovy/nextflow/sql/SqlDslTest.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/nextflow/sql/SqlDslTest.groovy rename to src/test/groovy/nextflow/sql/SqlDslTest.groovy diff --git a/plugins/nf-sqldb/src/test/nextflow/sql/config/SqlConfigTest.groovy b/src/test/groovy/nextflow/sql/config/SqlConfigTest.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/nextflow/sql/config/SqlConfigTest.groovy rename to src/test/groovy/nextflow/sql/config/SqlConfigTest.groovy diff --git a/plugins/nf-sqldb/src/test/nextflow/sql/config/SqlDataSourceTest.groovy b/src/test/groovy/nextflow/sql/config/SqlDataSourceTest.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/nextflow/sql/config/SqlDataSourceTest.groovy rename to src/test/groovy/nextflow/sql/config/SqlDataSourceTest.groovy diff --git a/plugins/nf-sqldb/src/test/test/BaseSpec.groovy b/src/test/groovy/test/BaseSpec.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/test/BaseSpec.groovy rename to src/test/groovy/test/BaseSpec.groovy diff --git a/plugins/nf-sqldb/src/test/test/helpers/MockHelpers.groovy b/src/test/groovy/test/helpers/MockHelpers.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/test/helpers/MockHelpers.groovy rename to src/test/groovy/test/helpers/MockHelpers.groovy diff --git a/plugins/nf-sqldb/src/test/test/helpers/TestHelper.groovy b/src/test/groovy/test/helpers/TestHelper.groovy similarity index 100% rename from plugins/nf-sqldb/src/test/test/helpers/TestHelper.groovy rename to src/test/groovy/test/helpers/TestHelper.groovy