[ 
https://issues.apache.org/jira/browse/RAT-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18033664#comment-18033664
 ] 

Claude Warren commented on RAT-163:
-----------------------------------

[~snazy] I want to thank you for having the interest and taking the time to 
create your WIP.

I do not know how Gradle plugins work so I don't have specific implementation 
comments.  However, I do know how the RAT configuration and reporting works and 
how we build the Ant and Maven plugins, so what I am about it provide is a 
general overview of how to think about the architecture.  See 
[https://creadur.apache.org/rat/development/ui_implementation.html] for an 
overview.

RAT is now a command line first design.  So all changes arrive as command line 
implementations first.  What this means for you is that all options will 
(should?) end up being specified as string representations.

The Ant and Maven implementations start life in the tools module..

First they use the OptionsCollection class to generate a list of option 
definitions specific the UI (Maven or Ant).  They create a list of MavenOption 
or AntOption objects found in the o.a.r.documentation.options package in the 
tools module.  The MavenOptions for example take all the long form CLI options 
(e.g. --input-ignore-file) and create maven specific formats (e.g. 
<InputIgnoreFile>).  Once you have properly constructed the OptionsCollection 
implementation it becomes trivial to generate documentation for the plugin that 
has all the proper format for the options as well as the descriptions and other 
attributes.

See [https://creadur.apache.org/rat/apache-rat/name_xref.html] for a cross 
reference example. or 
[https://creadur.apache.org/rat/apache-rat-tasks/ant_options.html] or 
[https://creadur.apache.org/rat/apache-rat-plugin/mvn_options.html] for Ant and 
Maven respectively.

The creation of a GradleOptions class will force you to think about how to 
implement the various options.

The second piece of code is a Generator.  the generator takes a collection of 
Options and writes base code for the UI.  So in your case the GradleGenerator 
will get a list of GradleOptions and generate base class that is extended by 
the final Gradle plugin.  For Ant and Maven this is done with a template file 
that is processed by the Generator implementation.

The templates are found in the tools resource directory.  The "args" template 
is code that manages a map of CLI option names to String values.  So for 
example in your "getStyleSheet" is called the result is converted into a string 
and args code "setArgs("style-sheet", fileNameString)" is called. 

When your plugin finally executes it populates the args and then uses the args 
to create the RAT configuration instance.  GradleOptions map to RAT options, 
setting the gradle option in the UI ends up setting the RAT option in the args, 
the args are used to generate the ReportConfiguration and then the 
ReportConfiguraiton is used to construct a Reporter which is called to do the 
work.

What your code needs to worry about is how to translate from Gradle to RAT 
Options and any bits that you don't support (for example Maven has its own help 
implementation so the RAT --help option is not supported in Maven), or options 
that are required to be set a specific way (for example Maven should generate 
an XML file when it runs so that the Maven report plugin can work properly.

Anyway, I hope this is not too much info and does not drive you away.  We are 
still in the 0.17 so we have time to change how the UI interface works.  Let's 
see if it works for Gradle and see what we need to change in RAT to make it 
easier.

Thanks again, and I look forward to hearing from you.

 

 

> Gradle Rat plugin
> -----------------
>
>                 Key: RAT-163
>                 URL: https://issues.apache.org/jira/browse/RAT-163
>             Project: Apache Rat
>          Issue Type: New Feature
>            Reporter: David Chen
>            Priority: Major
>
> A number of new Apache projects, such as Samza, are using Gradle. However, 
> there currently does not exist a Rat plugin for Gradle. The closest 
> alternative, the Gradle License Plugin 
> (https://github.com/hierynomus/license-gradle-plugin) is not flexible enough 
> compared to Rat for use cases such as defining exclusion rules.
> I have created a preliminary Gradle Rat plugin as part of SAMZA-285 and would 
> like to clean it up and make it a proper Gradle Rat plugin.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to