Class MavenUriCatalogResolver
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.javageneration.MavenUriCatalogResolver
-
public final class MavenUriCatalogResolver extends Object
Pre-processes an OASIS XML Catalog file by resolvingmaven:URIs into concretejar:file://URLs backed by artifacts in the local Maven repository.The
maven:URI schemeThe 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 AetherRepositorySystemto obtain the artifact's local file. The resolved URI becomes ajar:file:///…!/path/in/jarURL 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
Constructors Constructor Description 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancontainsMavenUris(String catalogText)Returnstrueif the given catalog file text contains at least onemaven:URI.Fileresolve(File originalCatalog, File resolvedCatalog)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 Detail
-
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 Detail
-
containsMavenUris
public static boolean containsMavenUris(String catalogText)
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
public void setProjectArtifacts(Set<org.apache.maven.artifact.Artifact> projectArtifacts)
Provides the set of resolved project artifacts.Must be called before
resolve(java.io.File, java.io.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
-
-