Skip to content

Commit

Permalink
Support the provided scope by the PomBuilder class
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Jun 23, 2024
1 parent e65668a commit 4f20fb2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/main/java/rife/bld/publish/PomBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public String build() {
if (dependencies() != null && !dependencies().isEmpty()) {
addDependencies(t, Scope.compile);
addDependencies(t, Scope.runtime);
addDependencies(t, Scope.provided);
t.setBlock("dependencies-tag");
}

Expand Down
66 changes: 49 additions & 17 deletions src/test/java/rife/bld/publish/TestPomBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,41 @@ void testDependenciesRuntime() {
""", builder.build());
}

@Test
void testDependenciesProvided() {
var builder = new PomBuilder();
builder.dependencies().scope(Scope.provided)
.include(new Dependency("org.eclipse.jetty.ee10", "jetty-ee10", new VersionNumber(12,0,7)))
.include(new Dependency("org.eclipse.jetty.ee10", "jetty-ee10-servlet", new VersionNumber(12,0,7)));
assertEquals("""
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<name></name>
<description></description>
<url></url>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10</artifactId>
<version>12.0.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
<version>12.0.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
""", builder.build());
}

@Test
void testDependencies() {
var builder = new PomBuilder();
Expand All @@ -428,9 +463,10 @@ void testDependencies() {
.include(new Dependency("org.springframework.boot", "spring-boot-starter", new VersionNumber(3, 0, 4))
.exclude("*", "artifactId"));
builder.dependencies().scope(Scope.runtime)
.include(new Dependency("com.uwyn.rife2", "rife2", VersionNumber.UNKNOWN, "agent"))
.include(new Dependency("org.eclipse.jetty", "jetty-server", new VersionNumber(11, 0, 14))
.exclude("*", "*").exclude("groupId", "artifactId"));
.include(new Dependency("com.uwyn.rife2", "rife2", VersionNumber.UNKNOWN, "agent"));
builder.dependencies().scope(Scope.provided)
.include(new Dependency("org.eclipse.jetty.ee10", "jetty-ee10", new VersionNumber(12,0,7)))
.include(new Dependency("org.eclipse.jetty.ee10", "jetty-ee10-servlet", new VersionNumber(12,0,7)));
assertEquals("""
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
Expand Down Expand Up @@ -475,20 +511,16 @@ void testDependencies() {
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>11.0.14</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
</exclusion>
</exclusions>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10</artifactId>
<version>12.0.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
<version>12.0.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Expand Down

0 comments on commit 4f20fb2

Please sign in to comment.