Menu

Tree [ec24a2] default tip /
 History

Read Only access


File Date Author Commit
 gradle 2022-09-06 Ernie Rael Ernie Rael [c38054] NamedServicesMergePlugin without tests
 namedservices-merge 2022-09-17 Ernie Rael Ernie Rael [ec24a2] PublishPlugins namedservices-merge 0.5.0
 .gitattributes 2022-09-06 Ernie Rael Ernie Rael [c38054] NamedServicesMergePlugin without tests
 .gitignore 2022-09-06 Ernie Rael Ernie Rael [c38054] NamedServicesMergePlugin without tests
 .hgignore 2022-09-06 Ernie Rael Ernie Rael [c38054] NamedServicesMergePlugin without tests
 README.rest 2022-09-17 Ernie Rael Ernie Rael [ec24a2] PublishPlugins namedservices-merge 0.5.0
 build.gradle 2022-09-06 Ernie Rael Ernie Rael [c38054] NamedServicesMergePlugin without tests
 gradle.properties 2022-09-17 Ernie Rael Ernie Rael [ec24a2] PublishPlugins namedservices-merge 0.5.0
 gradlew 2022-09-06 Ernie Rael Ernie Rael [c38054] NamedServicesMergePlugin without tests
 gradlew.bat 2022-09-06 Ernie Rael Ernie Rael [c38054] NamedServicesMergePlugin without tests
 settings.gradle 2022-09-06 Ernie Rael Ernie Rael [c38054] NamedServicesMergePlugin without tests

Read Me

PLUGIN: com.raelity.namedservices-merge

subproject: namedservices-merge

This plugin is used when creating fat-jar/uber-jar files and/or other situatins where jar files are combined. It merges the specified information found under META-INF/namedservices in the jars that combine to make up the jar tasks output.

The NetBeans Maven artifact org.netbeans.api:org-openide-util-lookup works in any plain old java project, see Lookup API. One of it's feature is @ServiceProvider and the associated Lookups.forPath to create/access namedservices.

Here's an example to merge the namedservice info from three subprojects, the current project and two other projects, jvi-core and jvi-swing, included in a fat-jar; these three projects are specified as inputLocations in the example build.gradle below. The java source code in the projects uses something like:

@ServiceProvider(service=ViInitialization.class,
                 path="jVi/init", position=##)

ViInitialization is in the package com.raelity.jvi.

Note that serviceProviderPath in namedservicesMerge extension accepts multiple paths; a separate merge task is created for each path. A project's existing jar task depends on these tasks.

Also note that for inputLocations one of the values is a closure referencing the other projects; it is not evaluated until it is needed.

For this example, the build.gradle set up is as follows:

plugins {
    id 'java'
    id 'com.raelity.namedservices-merge' version '0.5.0'
}

def input_projects = [ project(':jvi-core'), project(':jvi-swing') ]

namedservicesMerge {
   serviceProviderPath 'jVi/init/com.raelity.jvi.ViInitialization'
   inputLocations project.buildDir.toPath().resolve('classes'),
                  { input_projects.collect { it.jar.archiveFile.getAsFile() } }
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.