Given a Gradle web project that is to be published as a JAR (so that it can be a dependency of another Gradle web project, which has a different release cycle).
The maven-publish
plugin is used:
apply plugin: 'war'
apply plugin: 'maven'
apply plugin: 'maven-publish'
The web project has a providedCompile
dependency:
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
A jar
is published using mavenJava
:
publishing {
publications {
// mavenJava publishes a jar file
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
}
The problem is that javax.servlet-api
has a runtime
scope in the resulting Maven POM:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>runtime</scope>
</dependency>
Runtime scope makes no sense for the servlet-api, it is even harmful. How can the scope be set to provided
in the pom.xml?