From 841129544676ccbc265c07356594c39d84669a56 Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Thu, 12 Dec 2024 11:12:30 -0600 Subject: [PATCH] minor edits Signed-off-by: Ben Sherman --- .../nextflow/plugin/LocalUpdateRepository.groovy | 16 ++++++++-------- .../main/nextflow/plugin/PluginUpdater.groovy | 7 +++---- .../main/nextflow/plugin/PluginsFacade.groovy | 2 +- .../nextflow/plugin/PluginUpdaterTest.groovy | 7 +++---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/modules/nf-commons/src/main/nextflow/plugin/LocalUpdateRepository.groovy b/modules/nf-commons/src/main/nextflow/plugin/LocalUpdateRepository.groovy index 4188aaa1ea..ccc092fe1a 100644 --- a/modules/nf-commons/src/main/nextflow/plugin/LocalUpdateRepository.groovy +++ b/modules/nf-commons/src/main/nextflow/plugin/LocalUpdateRepository.groovy @@ -12,7 +12,6 @@ import org.pf4j.update.UpdateRepository import org.pf4j.update.verifier.CompoundVerifier import java.nio.file.Path -import java.nio.file.Paths /** * Implementation of UpdateRepository which looks in a local directory of already-downloaded @@ -20,7 +19,7 @@ import java.nio.file.Paths */ @CompileStatic @Slf4j -class LocalUpdateRepository implements UpdateRepository{ +class LocalUpdateRepository implements UpdateRepository { private final String id private final Path dir private Map plugins @@ -60,7 +59,7 @@ class LocalUpdateRepository implements UpdateRepository{ @Override FileDownloader getFileDownloader() { // plugins in this repo are already downloaded, so treat any download url as a file path - return (URL url) -> Paths.get(url.toURI()) + return (URL url) -> Path.of(url.toURI()) } @Override @@ -72,18 +71,19 @@ class LocalUpdateRepository implements UpdateRepository{ // each plugin is stored in a dir called $id-$version; grab the descriptor from each final manifestReader = new ManifestPluginDescriptorFinder() final descriptors = FilesEx.listFiles(dir) - .collect( plugin -> new LocalPlugin(plugin, manifestReader.find(plugin)) ) + .collect { plugin -> new LocalPlugin(plugin, manifestReader.find(plugin)) } // now group the descriptors by id, to create a PluginInfo with list of versions - return descriptors.groupBy { d -> d.getPluginId() } - .collectEntries { id, versions -> [id, toPluginInfo(id, versions)] } + return descriptors + .groupBy { d -> d.getPluginId() } + .collectEntries { id, versions -> List.of(id, toPluginInfo(id, versions)) } } private static PluginInfo toPluginInfo(String id, List versions) { - def info = new PluginInfo() + final info = new PluginInfo() info.id = id info.releases = versions.collect { v -> - def release = new PluginInfo.PluginRelease() + final release = new PluginInfo.PluginRelease() release.version = v.version release.requires = v.requires release.url = v.path.toUri().toURL() diff --git a/modules/nf-commons/src/main/nextflow/plugin/PluginUpdater.groovy b/modules/nf-commons/src/main/nextflow/plugin/PluginUpdater.groovy index c496ede2d2..cb9ada85d3 100644 --- a/modules/nf-commons/src/main/nextflow/plugin/PluginUpdater.groovy +++ b/modules/nf-commons/src/main/nextflow/plugin/PluginUpdater.groovy @@ -17,8 +17,6 @@ package nextflow.plugin -import org.pf4j.InvalidPluginDescriptorException - import static java.nio.file.StandardCopyOption.* import java.nio.file.Files @@ -38,6 +36,7 @@ import nextflow.SysEnv import nextflow.extension.FilesEx import nextflow.file.FileHelper import nextflow.file.FileMutex +import org.pf4j.InvalidPluginDescriptorException import org.pf4j.PluginDependency import org.pf4j.PluginRuntimeException import org.pf4j.PluginState @@ -207,7 +206,7 @@ class PluginUpdater extends UpdateManager { } private Path download0(String id, String version) { - // 0. check version is specified + // 0. check if version is specified if( !version ) throw new InvalidPluginDescriptorException("Missing version for plugin $id") log.info "Downloading plugin ${id}@${version}" @@ -422,7 +421,7 @@ class PluginUpdater extends UpdateManager { return false } if( offline ) { - log.debug("Update not supported in offline mode") + log.debug "Update not supported in offline mode" return false } diff --git a/modules/nf-commons/src/main/nextflow/plugin/PluginsFacade.groovy b/modules/nf-commons/src/main/nextflow/plugin/PluginsFacade.groovy index 04e04eb60f..72c5927dbd 100644 --- a/modules/nf-commons/src/main/nextflow/plugin/PluginsFacade.groovy +++ b/modules/nf-commons/src/main/nextflow/plugin/PluginsFacade.groovy @@ -46,12 +46,12 @@ class PluginsFacade implements PluginStateListener { private String mode private Path root + private boolean offline private PluginUpdater updater private CustomPluginManager manager private DefaultPlugins defaultPlugins = DefaultPlugins.INSTANCE private String indexUrl = Plugins.DEFAULT_PLUGINS_REPO private boolean embedded - private boolean offline PluginsFacade() { mode = getPluginsMode() diff --git a/modules/nf-commons/src/test/nextflow/plugin/PluginUpdaterTest.groovy b/modules/nf-commons/src/test/nextflow/plugin/PluginUpdaterTest.groovy index 82add48e7d..d709884fc4 100644 --- a/modules/nf-commons/src/test/nextflow/plugin/PluginUpdaterTest.groovy +++ b/modules/nf-commons/src/test/nextflow/plugin/PluginUpdaterTest.groovy @@ -1,8 +1,5 @@ package nextflow.plugin -import com.github.zafarkhaja.semver.Version -import org.pf4j.PluginRuntimeException - import java.nio.file.FileVisitResult import java.nio.file.Files import java.nio.file.Path @@ -12,18 +9,20 @@ import java.util.zip.ZipEntry import java.util.zip.ZipOutputStream import nextflow.BuildInfo +import com.github.zafarkhaja.semver.Version import org.pf4j.Plugin import org.pf4j.PluginDescriptor +import org.pf4j.PluginRuntimeException import org.pf4j.PluginWrapper import org.pf4j.update.PluginInfo import spock.lang.Specification import spock.lang.Unroll - /** * * @author Paolo Di Tommaso */ class PluginUpdaterTest extends Specification { + private static final String PLUGIN_ID = 'my-plugin' static class FooPlugin extends Plugin {