On 10/05/2012 09:16 PM, Kohsuke Kawaguchi wrote:
> an abstraction that capture common build spy events (source code in this directory got compiled with these libraries) across Ant/Maven/Gradle
By way of background, the code Kohsuke alluded to earlier was in NetBeans; the Ant runner reports build events through an SPI [1], and a plugin [2] can be told to listen
to events from a certain project’s build and watch for interesting tasks. In the case of an IDE, the primary focus is on source code, and there are SPIs (e.g. [3], [4])
which allow plugins to report information about projects—whether inferred as in this case, explicitly configured via IDE-specific means, or read from an existing standard
such as a Maven POM. The key is that the provision of this information (e.g. by a project type) and its consumption (e.g. by an editor) are decoupled, using API/SPI pairs
called “queries”.
In the Jenkins world, the analogous feature would be publishers (or other job attributes) which can obtain their configuration in several ways. Currently things like the
JUnit publisher are directly configured by the user. This is fine for freestyle projects, but is not very flexible:
1. In the case of a native Maven project, maven-plugin directly hardcodes a few core publishers—but not, say, code coverage or static analysis handled by other plugins,
even when the POM configures these mojos.
2. If you want to “sniff” build events to autoconfigure a project using a procedural build tool like Ant, you have to either make this a one-time wizard which does not
adapt to project refactorings; or live with the config.xml being repeatedly regenerated.
In other words, instead of an abstraction over build spies, what you may want is an abstraction over job configuration. Thus a plugin like JaCoCo would continue to define
a publisher that can be manually configured with the location of coverage results and other details, but can also be implicitly configured by a different plugin based on
arbitrary sources of information: POM parsing, spying on calls to the JaCoCo Ant task, or something else. There may also be kinds of information which would be consumed
by multiple plugins; for example, information about Java source roots, classpaths, and source levels would be of value to many plugins (definitely Sorcerer), and if
@Exported would be of value to external tools as well.
[1]
http://bits.netbeans.org/dev/javadoc/org-apache-tools-ant-module/org/apache/tools/ant/module/spi/AntLogger.html
[2]
http://wiki.netbeans.org/AutomaticProjects
[3]
http://bits.netbeans.org/dev/javadoc/org-netbeans-api-java-classpath/org/netbeans/spi/java/classpath/ClassPathProvider.html
[4]
http://bits.netbeans.org/dev/javadoc/org-netbeans-api-java/org/netbeans/spi/java/queries/SourceLevelQueryImplementation2.html