- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
feat: Add extension point interfaces for standalone plugin development #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Draft
      
      
            edmundmiller
  wants to merge
  2
  commits into
  master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
feat/extension-point-interfaces
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Draft
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1 +1 @@ | ||
| 1.0.0-beta.5 | ||
| 1.0.0-beta.6 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            72 changes: 72 additions & 0 deletions
          
          72 
        
  src/main/groovy/io/nextflow/gradle/extensions/CommandExtensionPoint.groovy
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| * Copyright 2013-2024, 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. | ||
| */ | ||
|  | ||
| package io.nextflow.gradle.extensions | ||
|  | ||
| import org.pf4j.ExtensionPoint | ||
|  | ||
| /** | ||
| * Extension point interface for plugins that want to register top-level CLI commands. | ||
| * | ||
| * Plugins implementing this interface can provide commands that appear as first-class | ||
| * citizens in the Nextflow CLI, accessible directly as 'nextflow <command>' rather than | ||
| * through the legacy 'nextflow plugin <pluginId>:<command>' syntax. | ||
| * | ||
| * Example: | ||
| * - Instead of: nextflow plugin nf-wave:get-container | ||
| * - Enable: nextflow wave get-container | ||
| * | ||
| * @author Edmund Miller <[email protected]> | ||
| */ | ||
| interface CommandExtensionPoint extends ExtensionPoint { | ||
|  | ||
| /** | ||
| * Get the primary command name that this plugin registers. | ||
| * This will be the top-level command name (e.g., "wave", "launch"). | ||
| * | ||
| * @return The command name that will be available at the top level | ||
| */ | ||
| String getCommandName() | ||
|  | ||
| /** | ||
| * Get the command description for help output. | ||
| * This description will appear in the main help listing. | ||
| * | ||
| * @return A brief description of what this command does | ||
| */ | ||
| String getCommandDescription() | ||
|  | ||
| /** | ||
| * Get the priority for this command extension. | ||
| * Higher priority commands will take precedence in case of name conflicts. | ||
| * Built-in commands have priority 1000 by default. | ||
| * | ||
| * @return Priority value (higher = higher priority), defaults to 100 | ||
| */ | ||
| default int getPriority() { return 100 } | ||
|  | ||
| /** | ||
| * Create the actual command instance that will handle execution. | ||
| * This method is called when the command needs to be instantiated. | ||
| * | ||
| * Note: This returns Object to avoid coupling the gradle plugin to Nextflow's CmdBase. | ||
| * Implementations should return a nextflow.cli.CmdBase instance. | ||
| * | ||
| * @return A CmdBase instance that will handle the command execution | ||
| */ | ||
| Object createCommand() | ||
|  | ||
| } | ||
        
          
          
            36 changes: 36 additions & 0 deletions
          
          36 
        
  src/main/groovy/io/nextflow/gradle/extensions/Factory.groovy
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright 2013-2024, 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. | ||
| * | ||
| */ | ||
|  | ||
| package io.nextflow.gradle.extensions | ||
|  | ||
| /** | ||
| * An annotation interface for channel factories that the plugin want to expose | ||
| * Nextflow will search for all methods annotated with @Factory in the ExtensionPoint and allow to the user imported them | ||
| * | ||
| * @author : jorge <[email protected]> | ||
| * | ||
| */ | ||
| import java.lang.annotation.ElementType | ||
| import java.lang.annotation.Retention | ||
| import java.lang.annotation.RetentionPolicy | ||
| import java.lang.annotation.Target | ||
|  | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target([ElementType.METHOD]) | ||
| @interface Factory { | ||
|  | ||
| } | 
        
          
          
            36 changes: 36 additions & 0 deletions
          
          36 
        
  src/main/groovy/io/nextflow/gradle/extensions/Function.groovy
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright 2013-2024, 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. | ||
| * | ||
| */ | ||
|  | ||
| package io.nextflow.gradle.extensions | ||
|  | ||
| /** | ||
| * An annotation interface for functions that the plugin want to expose | ||
| * Nextflow will search for all methods annotated with @Functions in the ExtensionPoint and allow to the user imported them | ||
| * | ||
| * @author : jorge <[email protected]> | ||
| * | ||
| */ | ||
| import java.lang.annotation.ElementType | ||
| import java.lang.annotation.Retention | ||
| import java.lang.annotation.RetentionPolicy | ||
| import java.lang.annotation.Target | ||
|  | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target([ElementType.METHOD]) | ||
| @interface Function { | ||
|  | ||
| } | 
        
          
          
            36 changes: 36 additions & 0 deletions
          
          36 
        
  src/main/groovy/io/nextflow/gradle/extensions/Operator.groovy
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright 2013-2024, 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. | ||
| * | ||
| */ | ||
|  | ||
| package io.nextflow.gradle.extensions | ||
|  | ||
| /** | ||
| * An annotation interface for operators that the plugin want to expose | ||
| * Nextflow will search for all methods annotated with @Operators in the ExtensionPoint and allow to the user imported them | ||
| * | ||
| * @author : jorge <[email protected]> | ||
| * | ||
| */ | ||
| import java.lang.annotation.ElementType | ||
| import java.lang.annotation.Retention | ||
| import java.lang.annotation.RetentionPolicy | ||
| import java.lang.annotation.Target | ||
|  | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target([ElementType.METHOD]) | ||
| @interface Operator { | ||
|  | ||
| } | 
        
          
          
            56 changes: 56 additions & 0 deletions
          
          56 
        
  src/main/groovy/io/nextflow/gradle/extensions/PluginExtensionPoint.groovy
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright 2013-2024, 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. | ||
| * | ||
| */ | ||
|  | ||
| package io.nextflow.gradle.extensions | ||
|  | ||
| import groovy.transform.PackageScope | ||
| import org.pf4j.ExtensionPoint | ||
|  | ||
| /** | ||
| * Define plugin extension points. A plugin can provide extension methods | ||
| * to add custom channel factories, channel operators and custom function | ||
| * in the including context. | ||
| * | ||
| * The extending subclass should mark the extension methods with the | ||
| * corresponding annotation {@link Factory}, {@link Operator} and {@link Function} | ||
| * | ||
| * Note: This returns Object for session to avoid coupling the gradle plugin | ||
| * to Nextflow's internal Session class. Implementations should expect a | ||
| * nextflow.Session instance. | ||
| * | ||
| * @author Paolo Di Tommaso <[email protected]> | ||
| */ | ||
| abstract class PluginExtensionPoint implements ExtensionPoint { | ||
|  | ||
| private boolean initialised | ||
|  | ||
| synchronized void checkInit(Object session) { | ||
| if( !initialised ) { | ||
| init(session) | ||
| initialised = true | ||
| } | ||
| } | ||
|  | ||
| /** | ||
| * Channel factory initialization. This method is invoked one and only once before | ||
| * the before target extension method is called. | ||
| * | ||
| * @param session The current nextflow Session (passed as Object to avoid coupling) | ||
| */ | ||
| abstract protected void init(Object session) | ||
|  | ||
| } | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be nextflow core classes/interfaces, not the other way around