Mojo
  1. Mojo
  2. MOJO-1272

serviceloader-maven-plugin (for java6 ServiceLoader)

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: _Plugin Submission
    • Labels:
      None
    • Environment:
      any
    • Complexity:
      Intermediate
    • Number of attachments :
      2

      Description

      I wrote a plugin that generates services files for the ServiceLoader
      introduced in Java 6 :
      http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html

      for example:
      <build>
      <plugins>
      <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>serviceloader-maven-plugin</artifactId>
      <configuration>
      <services>
      <param>com.foo.Dictionary</param>
      <param>com.foo.Operation</param>
      </services>
      </configuration>
      </plugin>
      </plugins>
      </build>

      this will generate these files:
      META-INF/services/com.foo.Dictionary
      META-INF/services/com.foo.Operation
      by scanning the generated classes and finding all
      non-abstract/non-interface implementations of the service interfaces.
      The plugin itself has no Java 6 dependency

        Activity

        Hide
        Andreas Schöneck added a comment -

        Patch to get the plugin work under Windows as well.

        Reamrk: Please excuse me for being quite new to creating patches on the console without having a version controlling system.

        Show
        Andreas Schöneck added a comment - Patch to get the plugin work under Windows as well. Reamrk: Please excuse me for being quite new to creating patches on the console without having a version controlling system.
        Hide
        Andreas Schöneck added a comment -

        Thank you for the plugin.
        I have made some corrections to it so it should work under various environments now:
        1. Add
        @requiresDependencyResolution compile
        to get dependencies into the classpath, e.g. for using an interface type from a dependency package
        2. Work with regular expressions
        3. Use File.separator instead of hardcoded "/"

        Show
        Andreas Schöneck added a comment - Thank you for the plugin. I have made some corrections to it so it should work under various environments now: 1. Add @requiresDependencyResolution compile to get dependencies into the classpath, e.g. for using an interface type from a dependency package 2. Work with regular expressions 3. Use File.separator instead of hardcoded "/"
        Hide
        Francis De Brabandere added a comment -

        Hi Andreas, since the plugin is not being picked up maybe we can put it somewhere on github or google code for now? We could then publish it in maven central through the sonatype staging repository...

        Show
        Francis De Brabandere added a comment - Hi Andreas, since the plugin is not being picked up maybe we can put it somewhere on github or google code for now? We could then publish it in maven central through the sonatype staging repository...
        Hide
        Milos Kleint added a comment -

        just a side note:

        I believe using annotations and jdk 1.6 annotation processors to generate META-INF services entries is more transparent and deterministic than examining the entire codebase.

        I'm not sure if there is a generic purpose annotation processor for this sort of thing, netbeans.org uses it's own version which does some additional stuff on top of the jdk serviceloader.

        http://hg.netbeans.org/main/file/7024baa3051f/openide.util.lookup/src/org/netbeans/modules/openide/util/ServiceProviderProcessor.java
        http://hg.netbeans.org/main/file/7024baa3051f/openide.util.lookup/src/org/openide/util/lookup/ServiceProvider.java

        Show
        Milos Kleint added a comment - just a side note: I believe using annotations and jdk 1.6 annotation processors to generate META-INF services entries is more transparent and deterministic than examining the entire codebase. I'm not sure if there is a generic purpose annotation processor for this sort of thing, netbeans.org uses it's own version which does some additional stuff on top of the jdk serviceloader. http://hg.netbeans.org/main/file/7024baa3051f/openide.util.lookup/src/org/netbeans/modules/openide/util/ServiceProviderProcessor.java http://hg.netbeans.org/main/file/7024baa3051f/openide.util.lookup/src/org/openide/util/lookup/ServiceProvider.java
        Hide
        Francis De Brabandere added a comment -

        Sounds like a good idea, maybe we can support both ways of scanning

        Show
        Francis De Brabandere added a comment - Sounds like a good idea, maybe we can support both ways of scanning
        Hide
        Andreas Schöneck added a comment -

        Hey Francis,
        I am quite surprised that you still monitor this issue, nice to see. I appreciate the code being transferred to somewhere else as well as supporting NetBeans loader stuff.

        Show
        Andreas Schöneck added a comment - Hey Francis, I am quite surprised that you still monitor this issue, nice to see. I appreciate the code being transferred to somewhere else as well as supporting NetBeans loader stuff.
        Hide
        Francis De Brabandere added a comment -

        I watch all the issues I create So where do we move the project?

        Show
        Francis De Brabandere added a comment - I watch all the issues I create So where do we move the project?
        Hide
        Andreas Schöneck added a comment -

        Since I am not very familiar to the various opensource communities out there and further it is your initial contribution, I think it is up to you to decide where to move. Since I am not very familiar with Git, I would prefer Google Code over Github since they offer Subversion. On the other hand I see a chance to get to know Git. What do you prefer?

        Show
        Andreas Schöneck added a comment - Since I am not very familiar to the various opensource communities out there and further it is your initial contribution, I think it is up to you to decide where to move. Since I am not very familiar with Git, I would prefer Google Code over Github since they offer Subversion. On the other hand I see a chance to get to know Git. What do you prefer?
        Hide
        Francis De Brabandere added a comment -

        code uploaded, patch applied but have better way for scanning classes now
        works with maven 3

        https://github.com/francisdb/serviceloader-maven-plugin

        Next step would be to have a look at the netbeans stuff?

        Show
        Francis De Brabandere added a comment - code uploaded, patch applied but have better way for scanning classes now works with maven 3 https://github.com/francisdb/serviceloader-maven-plugin Next step would be to have a look at the netbeans stuff?

          People

          • Assignee:
            Unassigned
            Reporter:
            Francis De Brabandere
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: