Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

190 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plexus Resources

Maven Central GitHub CI Reproducible Builds License

Retrieves a resource by name without the caller needing to know where it lives. ResourceManager tries a set of loaders in turn — the filesystem, the thread context classpath, a jar, a URL — and hands back a stream or a File.

Useful when a plugin accepts a configuration file that a user might supply as a path, as something on the classpath, or as a URL, and you would rather not write that lookup three times.

Status

Maintained, quietly. The API is small and settled; expect dependency updates rather than new features.

Using it

<dependency>
  <groupId>org.codehaus.plexus</groupId>
  <artifactId>plexus-resources</artifactId>
  <version>1.3.1</version>
</dependency>

Check the badge above for the current version.

@Inject
ResourceManager resourceManager;

resourceManager.addSearchPath( FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath() );

InputStream in = resourceManager.getResourceAsInputStream( "checkstyle.xml" );
File file = resourceManager.getResourceAsFile( "checkstyle.xml" );

getResourceAsFile will materialise a temporary file when the resource is not already one, so it works for classpath and URL resources too.

Requirements

Java 8 or later.

Documentation

Contributing

See CONTRIBUTING.md. In short: mvn verify builds, and run mvn spotless:apply before pushing or CI will fail on formatting.

Please report security vulnerabilities privately — see SECURITY.md, not a public issue.

About

Reads a resource from the filesystem, the classpath or a URL

Topics

Resources

Contributing

Security policy

Stars

2 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages