Class MavenUriCatalogResolver
maven: URIs into
concrete jar:file:// URLs backed by artifacts in the local Maven repository.
The maven: URI scheme
The scheme follows the format used by the jaxb-tools project:
maven:groupId:artifactId:type:classifier!/path/in/jar
Examples:
maven:com.example:shared-schemas:jar:!/schemas/common.xsdmaven:com.example:shared-schemas:jar::!/schemas/common.xsd(empty classifier)maven:com.example:shared-schemas:jar!/schemas/common.xsd(omit classifier segment)
Resolution
Each maven: URI is resolved via the Aether RepositorySystem to obtain the
artifact's local file. The resolved URI becomes a jar:file:///…!/path/in/jar URL that
XJC's built-in catalog support can follow without any further custom resolver.
Catalog pre-processing
The original catalog file is read, all maven:… occurrences are replaced, and the
result is written to a new file in the build directory. The new file path is returned and used
as the catalog argument to XJC in place of the original.
- Since:
- 4.1.1
-
Constructor Summary
ConstructorsConstructorDescriptionMavenUriCatalogResolver(org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession session, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories, org.apache.maven.plugin.logging.Log log) Creates a new resolver. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsMavenUris(String catalogText) Returnstrueif the given catalog file text contains at least onemaven:URI.ReadsoriginalCatalog, resolves allmaven:URIs within it tojar:file://URLs, and writes the result toresolvedCatalog.voidsetProjectArtifacts(Set<org.apache.maven.artifact.Artifact> projectArtifacts) Provides the set of resolved project artifacts.
-
Constructor Details
-
MavenUriCatalogResolver
public MavenUriCatalogResolver(org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession session, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories, org.apache.maven.plugin.logging.Log log) Creates a new resolver.- Parameters:
repositorySystem- Aether repository system, injected by the mojosession- the current repository system sessionremoteRepositories- the project's remote repositorieslog- the Maven build log
-
-
Method Details
-
containsMavenUris
Returnstrueif the given catalog file text contains at least onemaven:URI.Used as a fast-path guard: catalogs without
maven:references are passed straight to XJC without any pre-processing.- Parameters:
catalogText- the full text of the catalog file- Returns:
truewhen amaven:…!/…pattern is present
-
resolve
public File resolve(File originalCatalog, File resolvedCatalog) throws org.apache.maven.plugin.MojoExecutionException ReadsoriginalCatalog, resolves allmaven:URIs within it tojar:file://URLs, and writes the result toresolvedCatalog.If the catalog does not contain any
maven:URIs this method simply returnsoriginalCatalogwithout touching the filesystem.- Parameters:
originalCatalog- the user-supplied catalog fileresolvedCatalog- the target file for the pre-processed catalog in the build directory- Returns:
resolvedCatalogwhen anymaven:URIs were found and replaced, ororiginalCatalogif the file contained nomaven:URIs- Throws:
org.apache.maven.plugin.MojoExecutionException- if an artifact cannot be resolved or the file cannot be written
-
setProjectArtifacts
Provides the set of resolved project artifacts.Must be called before
resolve(File, File)when the catalog may containmaven:URIs. Typically populated fromMavenProject.getArtifacts()in the calling mojo.- Parameters:
projectArtifacts- the resolved artifacts of the current Maven project
-