JExten Maven Artifact Store
Maven repository integration for JExten plugin artifact resolution.
Overview
This module provides an ArtifactStore implementation that resolves plugin artifacts from Maven repositories. It enables plugins to specify dependencies using Maven coordinates, with automatic:
- Artifact resolution from local and remote Maven repositories
- Transitive dependency resolution
- Artifact caching in the local Maven repository
Installation
<dependency>
<groupId>org.myjtools.jexten</groupId>
<artifactId>jexten-maven-artifact-store</artifactId>
<version>1.0.0</version>
</dependency>
Quick Start
import org.myjtools.jexten.maven.artifactstore.MavenArtifactStore;
import org.myjtools.jexten.plugin.PluginManager;
// Create Maven artifact store
MavenArtifactStore artifactStore = new MavenArtifactStore();
// Create plugin manager with Maven support
PluginManager pluginManager = new PluginManager(
Path.of("plugins"),
artifactStore
);
// Load plugins - dependencies resolved from Maven
pluginManager.loadPlugins();
Configuration
Configure the artifact store using properties:
Properties props = new Properties();
// Local repository location
props.setProperty("localRepository", "/path/to/local/repo");
// Remote repositories (comma-separated)
props.setProperty("remoteRepositories",
"https://repo.maven.apache.org/maven2," +
"https://my-company.com/maven");
// Proxy configuration (optional)
props.setProperty("proxy.host", "proxy.company.com");
props.setProperty("proxy.port", "8080");
// Authentication (optional)
props.setProperty("repository.myrepo.username", "user");
props.setProperty("repository.myrepo.password", "pass");
MavenArtifactStore store = new MavenArtifactStore()
.configure(props);
Configuration Properties
| Property | Description | Default |
|---|---|---|
localRepository | Path to local Maven repository | ~/.m2/repository |
remoteRepositories | Comma-separated list of remote repository URLs | Maven Central |
proxy.host | HTTP proxy hostname | - |
proxy.port | HTTP proxy port | - |
proxy.username | Proxy authentication username | - |
proxy.password | Proxy authentication password | - |
offline | Work offline (use only local cache) | false |
Plugin Manifest Format
When using Maven artifact store, plugin manifests specify dependencies using a simplified format:
group: com.example
name: my-plugin
version: 1.0.0
hostModule: com.example.myplugin
artifacts:
# Format: groupId -> list of "artifactId-version"
org.apache.commons:
- commons-lang3-3.12.0
- commons-io-2.11.0
com.google.guava:
- guava-31.1-jre
The store resolves these to full Maven coordinates and fetches all transitive dependencies.
Dependency Scopes
The artifact store fetches dependencies with the following scopes:
| Scope | Included |
|---|---|
compile | Yes |
runtime | Yes |
provided | No |
test | No |
system | No |
Integration Example
Complete example with custom repository:
import org.myjtools.jexten.ExtensionManager;
import org.myjtools.jexten.maven.artifactstore.MavenArtifactStore;
import org.myjtools.jexten.plugin.PluginManager;
public class Application {
public static void main(String[] args) {
// Configure Maven artifact store
Properties mavenConfig = new Properties();
mavenConfig.setProperty("remoteRepositories",
"https://repo.maven.apache.org/maven2," +
"https://plugins.mycompany.com/maven");
MavenArtifactStore artifactStore = new MavenArtifactStore()
.configure(mavenConfig);
// Create plugin manager
PluginManager pluginManager = new PluginManager(
Path.of("plugins"),
artifactStore
);
// Load all plugins
pluginManager.loadPlugins();
// Create extension manager with plugin support
ExtensionManager extensions = ExtensionManager.create(pluginManager);
// Use extensions from both app and plugins
extensions.getExtensions(MyService.class)
.forEach(MyService::execute);
}
}
Caching Behavior
Artifacts are cached according to Maven conventions:
- Release versions: Cached permanently in local repository
- SNAPSHOT versions: Re-checked based on update policy
- Missing artifacts: Cached for configured timeout
Troubleshooting
"Could not resolve artifact"
- Check network connectivity
- Verify repository URLs are correct
- Check if artifact exists in configured repositories
- For private repositories, verify authentication
"Connection refused"
- Check proxy configuration if behind corporate firewall
- Verify repository URL is accessible
Slow resolution
- Use a local Maven repository mirror
- Configure offline mode for development
- Check network latency to remote repositories
Documentation
For complete documentation, see the main JExten README.
License
Apache License 2.0