mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-26 08:37:11 -07:00
Added support for generating POM properties.
Projects with javaRelease specified automatically set the maven compiler properties in their POM at generation.
This commit is contained in:
parent
a30b290c0d
commit
ecb9289001
9 changed files with 295 additions and 10 deletions
|
@ -50,12 +50,20 @@ public class TestPublishOperation {
|
|||
}
|
||||
}
|
||||
|
||||
static class PublishProject extends AppProjectBlueprint {
|
||||
public PublishProject(File work, String packageName, String projectName, VersionNumber versionNumber) {
|
||||
super(work, packageName, projectName, versionNumber);
|
||||
javaRelease = 19;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInstantiation() {
|
||||
var operation = new PublishOperation();
|
||||
assertTrue(operation.repositories().isEmpty());
|
||||
assertNull(operation.moment());
|
||||
assertTrue(operation.dependencies().isEmpty());
|
||||
assertTrue(operation.properties().isEmpty());
|
||||
assertNotNull(operation.info());
|
||||
assertNull(operation.info().groupId());
|
||||
assertNull(operation.info().artifactId());
|
||||
|
@ -105,6 +113,7 @@ public class TestPublishOperation {
|
|||
.repository(repository2)
|
||||
.moment(moment)
|
||||
.artifacts(List.of(artifact1, artifact2));
|
||||
operation3.properties().mavenCompilerSource(17).mavenCompilerTarget(19);
|
||||
assertTrue(operation3.repositories().contains(repository1));
|
||||
assertTrue(operation3.repositories().contains(repository2));
|
||||
assertEquals(moment, operation3.moment());
|
||||
|
@ -195,7 +204,7 @@ public class TestPublishOperation {
|
|||
// created an updated publication
|
||||
var create_operation2 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 0, 0));
|
||||
return new PublishProject(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 0, 0));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp2)
|
||||
|
@ -328,7 +337,7 @@ public class TestPublishOperation {
|
|||
// created an updated publication
|
||||
var create_operation2 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 0, 0));
|
||||
return new PublishProject(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 0, 0));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp2)
|
||||
|
@ -405,7 +414,7 @@ public class TestPublishOperation {
|
|||
// create a first publication
|
||||
var create_operation1 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
return new PublishProject(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp1)
|
||||
|
@ -482,7 +491,7 @@ public class TestPublishOperation {
|
|||
// created an updated publication
|
||||
var create_operation2 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
return new PublishProject(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp2)
|
||||
|
@ -575,7 +584,7 @@ public class TestPublishOperation {
|
|||
// create a first publication
|
||||
var create_operation1 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
return new PublishProject(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp1)
|
||||
|
@ -631,7 +640,7 @@ public class TestPublishOperation {
|
|||
// created an updated publication
|
||||
var create_operation2 = new CreateAppOperation() {
|
||||
protected Project createProjectBlueprint() {
|
||||
return new AppProjectBlueprint(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
return new PublishProject(new File(workDirectory(), projectName()), packageName(), projectName(), new VersionNumber(1, 2, 3, "SNAPSHOT"));
|
||||
}
|
||||
}
|
||||
.workDirectory(tmp2)
|
||||
|
|
|
@ -22,6 +22,7 @@ public class TestPomBuilder {
|
|||
void testInstantiation() {
|
||||
var builder = new PomBuilder();
|
||||
assertNull(builder.info());
|
||||
assertTrue(builder.properties().isEmpty());
|
||||
assertTrue(builder.dependencies().isEmpty());
|
||||
}
|
||||
|
||||
|
@ -197,6 +198,29 @@ public class TestPomBuilder {
|
|||
""", builder.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCompilerPropertiesBuild() {
|
||||
var builder = new PomBuilder()
|
||||
.properties(new PublishProperties().mavenCompilerSource(22).mavenCompilerTarget(19));
|
||||
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>
|
||||
<properties>
|
||||
<maven.compiler.source>22</maven.compiler.source>
|
||||
<maven.compiler.target>19</maven.compiler.target>
|
||||
</properties>
|
||||
</project>
|
||||
""", builder.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFullInfoBuild() {
|
||||
var builder = new PomBuilder()
|
||||
|
@ -486,7 +510,8 @@ public class TestPomBuilder {
|
|||
.developer(new PublishDeveloper().id("id1").name("name1").email("email1").url("url1"))
|
||||
.developer(new PublishDeveloper().id("id2").name("name2"))
|
||||
.developer(new PublishDeveloper().id("id3").name("name3").url("url3"))
|
||||
.scm(new PublishScm().connection("conn1").developerConnection("devconn1").url("url1")));
|
||||
.scm(new PublishScm().connection("conn1").developerConnection("devconn1").url("url1")))
|
||||
.properties(new PublishProperties().mavenCompilerSource(22).mavenCompilerTarget(19));
|
||||
builder.dependencies().scope(Scope.compile)
|
||||
.include(new Dependency("com.uwyn.rife2", "rife2"))
|
||||
.include(new Dependency("com.uwyn.rife2", "rife2", new VersionNumber(1, 5, 5), "bld", "zip"))
|
||||
|
@ -517,6 +542,10 @@ public class TestPomBuilder {
|
|||
<url>https://license2.com</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<properties>
|
||||
<maven.compiler.source>22</maven.compiler.source>
|
||||
<maven.compiler.target>19</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.uwyn.rife2</groupId>
|
||||
|
|
93
src/test/java/rife/bld/publish/TestPublishProperties.java
Normal file
93
src/test/java/rife/bld/publish/TestPublishProperties.java
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright 2001-2024 Geert Bevin (gbevin[remove] at uwyn dot com)
|
||||
* Licensed under the Apache License, Version 2.0 (the "License")
|
||||
*/
|
||||
package rife.bld.publish;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class TestPublishProperties {
|
||||
@Test
|
||||
public void testMavenCompilerSourceDefaultValue() {
|
||||
var publishProperties = new PublishProperties();
|
||||
var actualValue = publishProperties.mavenCompilerSource();
|
||||
assertNull(actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerSourceSetterWhenValueIsNotNull() {
|
||||
var publishProperties = new PublishProperties();
|
||||
Integer testValue = 15;
|
||||
publishProperties.mavenCompilerSource(testValue);
|
||||
Integer actualValue = Integer.parseInt(publishProperties.get("maven.compiler.source"));
|
||||
assertEquals(testValue, actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerSourceSetterWhenValueIsNull() {
|
||||
var publishProperties = new PublishProperties();
|
||||
publishProperties.mavenCompilerSource(null);
|
||||
var actualValue = publishProperties.get("maven.compiler.source");
|
||||
assertNull(actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerSourceGetterWhenValueIsNotNull() {
|
||||
var publishProperties = new PublishProperties();
|
||||
Integer testValue = 8;
|
||||
publishProperties.put("maven.compiler.source", String.valueOf(testValue));
|
||||
var actualValue = publishProperties.mavenCompilerSource();
|
||||
assertEquals(testValue, actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerSourceGetterWhenValueIsNull() {
|
||||
var publishProperties = new PublishProperties();
|
||||
publishProperties.put("maven.compiler.source", null);
|
||||
var actualValue = publishProperties.mavenCompilerSource();
|
||||
assertNull(actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerTargetDefaultValue() {
|
||||
var publishProperties = new PublishProperties();
|
||||
var actualValue = publishProperties.mavenCompilerTarget();
|
||||
assertNull(actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerTargetSetterWhenValueIsNotNull() {
|
||||
var publishProperties = new PublishProperties();
|
||||
Integer testValue = 15;
|
||||
publishProperties.mavenCompilerTarget(testValue);
|
||||
Integer actualValue = Integer.parseInt(publishProperties.get("maven.compiler.target"));
|
||||
assertEquals(testValue, actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerTargetSetterWhenValueIsNull() {
|
||||
var publishProperties = new PublishProperties();
|
||||
publishProperties.mavenCompilerTarget(null);
|
||||
var actualValue = publishProperties.get("maven.compiler.target");
|
||||
assertNull(actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerTargetGetterWhenValueIsNotNull() {
|
||||
var publishProperties = new PublishProperties();
|
||||
Integer testValue = 8;
|
||||
publishProperties.put("maven.compiler.target", String.valueOf(testValue));
|
||||
var actualValue = publishProperties.mavenCompilerTarget();
|
||||
assertEquals(testValue, actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMavenCompilerTargetGetterWhenValueIsNull() {
|
||||
var publishProperties = new PublishProperties();
|
||||
publishProperties.put("maven.compiler.target", null);
|
||||
var actualValue = publishProperties.mavenCompilerTarget();
|
||||
assertNull(actualValue);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue