在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):francisdb/serviceloader-maven-plugin开源软件地址(OpenSource Url):https://github.com/francisdb/serviceloader-maven-plugin开源编程语言(OpenSource Language):Java 100.0%开源软件介绍(OpenSource Introduction):This maven plugin generates services files for the ServiceLoader introduced in Java 6 : https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html Usefor example: <build>
<plugins>
<plugin>
<groupId>eu.somatik.serviceloader-maven-plugin</groupId>
<artifactId>serviceloader-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<services>
<param>com.foo.Dictionary</param>
<param>com.foo.Operation</param>
</services>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> this will generate these files:
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 Excludes / includesAdditionally it is possible to filter implementation classes via includes and excludes section in the configuration. The class name notation is the same as for the services section. for example: <build>
<plugins>
<plugin>
<groupId>eu.somatik.serviceloader-maven-plugin</groupId>
<artifactId>serviceloader-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<services>
<param>com.foo.Dictionary</param>
<param>com.foo.Operation</param>
</services>
<includes>
<include>*.RightClass*</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> This should add only implementation classes that begin with RightClass*. Missing Service ClassesThe default action when a service class is missing is to fail the build.
If you want to ignore this service, you can use the for example: <build>
<plugins>
<plugin>
<groupId>eu.somatik.serviceloader-maven-plugin</groupId>
<artifactId>serviceloader-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<failOnMissingServiceClass>false</failOnMissingServiceClass>
<services>
<param>com.foo.MissingService</param>
</services>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> ExampleA example project is provided and can be run like this:
ReleaseNote: do
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论