Skip to content

Commit

Permalink
feat: remove buildSrc/ and make Gradle build robust
Browse files Browse the repository at this point in the history
  • Loading branch information
clintval committed Nov 22, 2023
1 parent 0ddd087 commit 2286f2e
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 110 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ jobs:
- name: Compile
run: |
make clean
make check
make compile
make compile-with-nextflow
- name: Test
run: make test
env:
GRADLE_OPTS: '-Dorg.gradle.daemon=false'

- name: Build
run: make build

- name: Install
run: make install-local

- name: Test
run: make test
env:
GRADLE_OPTS: '-Dorg.gradle.daemon=false'
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version ?= $(shell grep 'Plugin-Version' plugins/nf-dotenv/src/resources/META-INF/MANIFEST.MF | awk '{ print $$2 }')

.PHONY: check
check:
./gradlew check --warning-mode all
.PHONY: all
all: compile build

.PHONY: clean
clean:
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# nf-dotenv

[![CI](https:/fulcrumgenomics/nf-dotenv/actions/workflows/test.yml/badge.svg?branch=main)](https:/fulcrumgenomics/nf-dotenv/actions/workflows/test.yml?query=branch%3Amain)
[![Nextflow](https://img.shields.io/badge/Nextflow%20DSL2-%E2%89%A522.10.0-blue.svg)](https://www.nextflow.io/)
[![Nextflow](https://img.shields.io/badge/Nextflow%20DSL2-%E2%89%A522.10.2-blue.svg)](https://www.nextflow.io/)
[![Java Versions](https://img.shields.io/badge/java-8_|_11_|_17_|_21-blue)](https:/fulcrumgenomics/nf-dotenv)

Automatically source [dotenv](https://hexdocs.pm/dotenvy/dotenv-file-format.html) files into your Nextflow scope.
Expand Down Expand Up @@ -119,10 +119,9 @@ samtools 1.16

## Testing the Plugin Locally

Execute the following to check, compile, and run unit tests for the plugin:
Execute the following to compile and run unit tests for the plugin:

```
make check
make compile
make test
```
Expand Down
7 changes: 0 additions & 7 deletions buildSrc/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
groovyVersion = 3.0.14
nextflowVersion = 22.10.2
43 changes: 18 additions & 25 deletions plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import io.nextflow.gradle.tasks.GithubRepositoryPublisher
import io.nextflow.gradle.tasks.GithubUploader
import org.apache.commons.codec.digest.DigestUtils
Expand All @@ -22,6 +21,7 @@ import java.time.format.DateTimeFormatter

plugins {
id "java"
id "groovy"
id "io.nextflow.nf-build-plugin" version "1.0.1"
}

Expand All @@ -32,22 +32,25 @@ ext.github_commit_email = project.findProperty('github_commit_email') ?: System.

jar.enabled = false

/** Generate a sha512 hash of the given file. */
static String computeSha512(File file) {
if (!file.exists())
if (!file.exists()) {
throw new GradleException("Missing file: $file -- cannot compute SHA-512")
}
return DigestUtils.sha512Hex(file.bytes)
}

/** The time is now! */
String now() {
"${OffsetDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME)}"
}

/** All the plugins we intend to compile, test, build, install, and publish. */
List<String> allPlugins() {
def plugins = []
new File(rootProject.rootDir, 'plugins') .eachDir { if(it.name.startsWith('nf-')) plugins.add(it.name) }
return plugins
return [new File(rootProject.rootDir, 'plugins/nf-dotenv')] as List<String>
}

/** Get the metadata for this plugin from the MANIFEST file. */
static String metaFromManifest(String meta, File file) {
def str = file.text
def regex = ~/(?m)^$meta:\s*([\w-\.<>=]+)$/
Expand All @@ -71,7 +74,7 @@ subprojects {
mavenCentral()
}

version = metaFromManifest('Plugin-Version',file('src/resources/META-INF/MANIFEST.MF'))
version = metaFromManifest('Plugin-Version', file('src/resources/META-INF/MANIFEST.MF'))

tasks.withType(Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
Expand All @@ -97,7 +100,7 @@ subprojects {
"requires": "${metaFromManifest('Plugin-Requires', file('src/resources/META-INF/MANIFEST.MF'))}",
"sha512sum": "${computeSha512(zip)}"
}
""".stripIndent()
""".stripTrailing().stripIndent()
file("$buildDir/tmp/makeZip").deleteDir()
}
outputs.file("$buildDir/libs/${project.name}-${project.version}.zip")
Expand All @@ -107,18 +110,19 @@ subprojects {
tasks.register('copyPluginLibs', Sync) {
from configurations.runtimeClasspath
into 'build/target/libs'
duplicatesStrategy 'exclude'
}

/** Copy the plugin into the project root build/plugins directory. */
tasks.register('copyPluginZip', Copy) {
dependsOn project.tasks.findByName('makeZip')
dependsOn 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}"
src: "$rootProject.buildDir/plugins/${project.name}-${project.version}.zip",
dest: "$rootProject.buildDir/plugins/${project.name}-${project.version}"
)
}
}
Expand All @@ -129,8 +133,10 @@ subprojects {
tasks.register('uploadPlugin', GithubUploader) {
dependsOn makeZip
assets = providers.provider {
["$buildDir/libs/${project.name}-${project.version}.zip",
"$buildDir/libs/${project.name}-${project.version}-meta.json"]
[
"$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 }
Expand All @@ -139,19 +145,6 @@ subprojects {
authToken = github_access_token
skipExisting = true
}

jar {
from sourceSets.main.allSource
doLast {
file("$buildDir/tmp/jar").deleteDir()
}
}

tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}

task upload(dependsOn: [uploadPlugin] ) { }
}

/** Upload all plugins to the corresponding GitHub repos. */
Expand Down
35 changes: 19 additions & 16 deletions plugins/nf-dotenv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
// TODO: Figure out how to build all this for cross-Java support without needing ./buildSrc!
id 'io.nextflow.groovy-library-conventions'
id 'groovy'
id 'idea'
}

group = 'io.nextflow'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}


idea {
module.inheritOutputDirs = true
}
Expand All @@ -46,33 +51,31 @@ sourceSets {
test.resources.srcDirs = ['src/testResources']
}

ext {
nextflowVersion = '23.04.0'
}

dependencies {
// This dependency is exported to consumers, that is to say, it is found on their compile classpath.
compileOnly "io.nextflow:nextflow:$nextflowVersion"
compileOnly 'org.slf4j:slf4j-api:2.0.9'
compileOnly 'org.pf4j:pf4j:3.10.0'
compileOnly 'org.slf4j:slf4j-api:1.7.10'
compileOnly 'org.pf4j:pf4j:3.4.1'

// Plugin dependencies.
implementation 'io.github.cdimascio:dotenv-java:3.0.0'

// Test configuration.
testImplementation "org.codehaus.groovy:groovy:3.0.19"
testImplementation "org.codehaus.groovy:groovy-nio:3.0.19"
testImplementation "io.nextflow:nextflow:$nextflowVersion"
testImplementation ("org.codehaus.groovy:groovy-test:3.0.19") { exclude group: 'org.codehaus.groovy' }
testImplementation "org.codehaus.groovy:groovy:$groovyVersion"
testImplementation "org.codehaus.groovy:groovy-nio:$groovyVersion"
testImplementation ("org.codehaus.groovy:groovy-test:$groovyVersion") { exclude group: 'org.codehaus.groovy' }
testImplementation ("cglib:cglib-nodep:3.3.0")
testImplementation ("org.objenesis:objenesis:3.3")
testImplementation ("org.spockframework:spock-core:2.3-groovy-3.0") { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' }
testImplementation ('org.spockframework:spock-junit4:2.3-groovy-3.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' }
testImplementation ('com.google.jimfs:jimfs:1.3.0')
testImplementation ("org.objenesis:objenesis:3.1")
testImplementation ("org.spockframework:spock-core:2.0-M3-groovy-3.0") { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' }
testImplementation ('org.spockframework:spock-junit4:2.0-M3-groovy-3.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' }

testImplementation(testFixtures("io.nextflow:nextflow:$nextflowVersion"))
testImplementation(testFixtures("io.nextflow:nf-commons:$nextflowVersion"))

testImplementation("org.junit.jupiter:junit-jupiter:5.9.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

// 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") }
Expand Down

0 comments on commit 2286f2e

Please sign in to comment.