Universal maven:
urls handling module. Can be used in Wildfly and Tomcat (Spring Boot) applications.
Handling URL protocol for maven dependency format (like other protocols: http
, file
, ftp
etc.), example:
maven:hu.icellmobilsoft.coffee:coffee-dto-xsd:jar::!/xsd/hu/icellmobilsoft/coffee/dto/common/common.xsd
The format is: maven:groupId:artifactId:package:version:!file_path
-
protocol
- the URL schema protocol [maven] -
groupId
- the maven groupId [hu.icellmobilsoft.coffee.dto.xsd] -
artifactId
- the maven artifactId [coffee-dto-xsd] -
package
- the maven package [jar] -
version
- the maven version, optional -
file_path
- the path of the .xsd file inside the jar
To properly use this module, the java URL protocol handler must be registered in the application server. It can be done by adding the module to the server, or by adding the handler to the application.
This artifact must be installed as a wildfly module and server must be started with the additional JAVA_OPT value: -Djboss.protocol.handler.modules=com.btmssds.maven.protocol
installing with jboss-cli.sh
module add --name=com.btmssds.maven.protocol --resources=maven-url-handler-module-1.0.0.jar
import jakarta.annotation.PostConstruct;
import com.btmssds.maven.protocol.MavenUrlStreamHandlerProvider;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.springframework.context.annotation.Configuration;
@Configuration
public class Starter {
@PostConstruct
private void init() {
TomcatURLStreamHandlerFactory.getInstance().addUserFactory(new MavenUrlStreamHandlerProvider());
}
}
<dependency>
<groupId>com.btmssds.urlhandler</groupId>
<artifactId>maven-url-handler-module</artifactId>
<version>VERSION</version>
</dependency>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<public
publicId="http://common.dto.coffee.icellmobilsoft.hu/common"
uri="maven:hu.icellmobilsoft.coffee:coffee-dto-xsd:jar::!/xsd/hu/icellmobilsoft/coffee/dto/common/common.xsd" /> (1)
</catalog>
-
Schema definition will be read from the maven artifact
hu.icellmobilsoft.coffee:coffee-dto-xsd:jar
from the path/xsd/hu/icellmobilsoft/coffee/dto/common/common.xsd