Getting all the archives in a RuleSource plugin?

plugins

(Appu Goundan) #1

I have a RuleSource plugin that looks for archives to deploy. What I want to do is inspect all the archives generated by jar/war/assemble or whatever. I’m not familiar enough with the RuleSource stuff and have been having an especially difficult time finding any documentation on @Binary...… annotations (whether they are relevant or not).

Are there any examples or documentation on how to process a gradle project’s artifacts after they are generated from a RuleSource plugin task?


(John Scancella) #2

I too would be interested in this. I am in the middle of converting a plugin to use the new rules based. I am looking to replace the line getProject().getConfigurations().getByName("archives").getAllArtifacts().getFiles();


(Appu Goundan) #3

Actually looking through gradle sources to see if I could find any tricks, I found JvmComponentPlugin which has a JarBinarySpec, presumably an addition to the java plugin? Couldn’t find anything yet for wars though. :telescope:


(John Scancella) #4

I ended up figuring it out manually and passing it into my custom action

Set<File> artifacts = new HashSet<>();

for(Task task : tasks){
        if(task instanceof AbstractArchiveTask){
          myTask.dependsOn(task);
          artifacts.add(((AbstractArchiveTask)task).getArchivePath());
        }
      }
      
myTask.getActions().add(new myAction(myConfig, artifacts));