3131import org .springframework .boot .build .bom .Library .ProhibitedVersion ;
3232import org .springframework .boot .build .bom .Library .VersionAlignment ;
3333import org .springframework .boot .build .bom .bomr .version .DependencyVersion ;
34+ import org .springframework .boot .build .properties .BuildType ;
3435
3536import static org .assertj .core .api .Assertions .assertThat ;
3637
4243 */
4344class AntoraAsciidocAttributesTests {
4445
46+ @ Test
47+ void buildTypeWhenOpenSource () {
48+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType .OPEN_SOURCE , null ,
49+ mockDependencyVersions (), null );
50+ assertThat (attributes .get ()).containsEntry ("build-type" , "opensource" );
51+ }
52+
53+ @ Test
54+ void buildTypeWhenCommercial () {
55+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType .COMMERCIAL , null ,
56+ mockDependencyVersions (), null );
57+ assertThat (attributes .get ()).containsEntry ("build-type" , "commercial" );
58+ }
59+
4560 @ Test
4661 void githubRefWhenReleasedVersionIsTag () {
47- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
62+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
4863 mockDependencyVersions (), null );
4964 assertThat (attributes .get ()).containsEntry ("github-ref" , "v1.2.3" );
5065 }
5166
5267 @ Test
5368 void githubRefWhenLatestSnapshotVersionIsMainBranch () {
54- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , null ,
55- mockDependencyVersions (), null );
69+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true ,
70+ BuildType . OPEN_SOURCE , null , mockDependencyVersions (), null );
5671 assertThat (attributes .get ()).containsEntry ("github-ref" , "main" );
5772 }
5873
5974 @ Test
6075 void githubRefWhenOlderSnapshotVersionIsBranch () {
61- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , false , null ,
62- mockDependencyVersions (), null );
76+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , false ,
77+ BuildType . OPEN_SOURCE , null , mockDependencyVersions (), null );
6378 assertThat (attributes .get ()).containsEntry ("github-ref" , "1.2.x" );
6479 }
6580
6681 @ Test
6782 void githubRefWhenOlderSnapshotHotFixVersionIsBranch () {
68- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false , null ,
69- mockDependencyVersions (), null );
83+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false ,
84+ BuildType . OPEN_SOURCE , null , mockDependencyVersions (), null );
7085 assertThat (attributes .get ()).containsEntry ("github-ref" , "1.2.3.x" );
7186 }
7287
7388 @ Test
7489 void versionReferenceFromLibrary () {
7590 Library library = mockLibrary (Collections .emptyMap ());
76- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false , List . of ( library ),
77- mockDependencyVersions (), null );
91+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false ,
92+ BuildType . OPEN_SOURCE , List . of ( library ), mockDependencyVersions (), null );
7893 assertThat (attributes .get ()).containsEntry ("version-spring-framework" , "1.2.3" );
7994 }
8095
8196 @ Test
8297 void versionReferenceFromSpringDataDependencyReleaseVersion () {
83- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
98+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
8499 mockDependencyVersions ("3.2.5" ), null );
85100 assertThat (attributes .get ()).containsEntry ("version-spring-data-mongodb-docs" , "3.2" );
86101 assertThat (attributes .get ()).containsEntry ("version-spring-data-mongodb-javadoc" , "3.2.x" );
87102 }
88103
89104 @ Test
90105 void versionReferenceFromSpringDataDependencySnapshotVersion () {
91- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
106+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
92107 mockDependencyVersions ("3.2.0-SNAPSHOT" ), null );
93108 assertThat (attributes .get ()).containsEntry ("version-spring-data-mongodb-docs" , "3.2-SNAPSHOT" );
94109 assertThat (attributes .get ()).containsEntry ("version-spring-data-mongodb-javadoc" , "3.2.x" );
95110 }
96111
97112 @ Test
98113 void versionNativeBuildTools () {
99- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
114+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
100115 mockDependencyVersions (), Map .of ("nativeBuildToolsVersion" , "3.4.5" ));
101116 assertThat (attributes .get ()).containsEntry ("version-native-build-tools" , "3.4.5" );
102117 }
103118
104119 @ Test
105120 void urlArtifactRepositoryWhenRelease () {
106- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
121+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
107122 mockDependencyVersions (), null );
108123 assertThat (attributes .get ()).containsEntry ("url-artifact-repository" , "https://repo.maven.apache.org/maven2" );
109124 }
110125
111126 @ Test
112127 void urlArtifactRepositoryWhenMilestone () {
113- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , null ,
114- mockDependencyVersions (), null );
128+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , BuildType . OPEN_SOURCE ,
129+ null , mockDependencyVersions (), null );
115130 assertThat (attributes .get ()).containsEntry ("url-artifact-repository" , "https://repo.spring.io/milestone" );
116131 }
117132
118133 @ Test
119134 void urlArtifactRepositoryWhenSnapshot () {
120- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , null ,
121- mockDependencyVersions (), null );
135+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true ,
136+ BuildType . OPEN_SOURCE , null , mockDependencyVersions (), null );
122137 assertThat (attributes .get ()).containsEntry ("url-artifact-repository" , "https://repo.spring.io/snapshot" );
123138 }
124139
125140 @ Test
126- void artifactReleaseTypeWhenRelease () {
127- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , null ,
141+ void artifactReleaseTypeWhenOpenSourceRelease () {
142+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType . OPEN_SOURCE , null ,
128143 mockDependencyVersions (), null );
129144 assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "release" );
145+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "opensource-release" );
130146 }
131147
132148 @ Test
133- void artifactReleaseTypeWhenMilestone () {
134- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , null ,
135- mockDependencyVersions (), null );
149+ void artifactReleaseTypeWhenOpenSourceMilestone () {
150+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , BuildType . OPEN_SOURCE ,
151+ null , mockDependencyVersions (), null );
136152 assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "milestone" );
153+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "opensource-milestone" );
137154 }
138155
139156 @ Test
140- void artifactReleaseTypeWhenSnapshot () {
141- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , null ,
157+ void artifactReleaseTypeWhenOpenSourceSnapshot () {
158+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true ,
159+ BuildType .OPEN_SOURCE , null , mockDependencyVersions (), null );
160+ assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "snapshot" );
161+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "opensource-snapshot" );
162+ }
163+
164+ @ Test
165+ void artifactReleaseTypeWhenCommercialRelease () {
166+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3" , true , BuildType .COMMERCIAL , null ,
167+ mockDependencyVersions (), null );
168+ assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "release" );
169+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "commercial-release" );
170+ }
171+
172+ @ Test
173+ void artifactReleaseTypeWhenCommercialMilestone () {
174+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-M1" , true , BuildType .COMMERCIAL , null ,
142175 mockDependencyVersions (), null );
176+ assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "milestone" );
177+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "commercial-milestone" );
178+ }
179+
180+ @ Test
181+ void artifactReleaseTypeWhenCommercialSnapshot () {
182+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , BuildType .COMMERCIAL ,
183+ null , mockDependencyVersions (), null );
143184 assertThat (attributes .get ()).containsEntry ("artifact-release-type" , "snapshot" );
185+ assertThat (attributes .get ()).containsEntry ("build-and-artifact-release-type" , "commercial-snapshot" );
144186 }
145187
146188 @ Test
@@ -149,16 +191,16 @@ void urlLinksFromLibrary() {
149191 links .put ("site" , (version ) -> "https://example.com/site/" + version );
150192 links .put ("docs" , (version ) -> "https://example.com/docs/" + version );
151193 Library library = mockLibrary (links );
152- AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false , List . of ( library ),
153- mockDependencyVersions (), null );
194+ AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes ("1.2.3.1-SNAPSHOT" , false ,
195+ BuildType . OPEN_SOURCE , List . of ( library ), mockDependencyVersions (), null );
154196 assertThat (attributes .get ()).containsEntry ("url-spring-framework-site" , "https://example.com/site/1.2.3" )
155197 .containsEntry ("url-spring-framework-docs" , "https://example.com/docs/1.2.3" );
156198 }
157199
158200 @ Test
159201 void linksFromProperties () {
160- Map <String , String > attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , null ,
161- mockDependencyVersions (), null )
202+ Map <String , String > attributes = new AntoraAsciidocAttributes ("1.2.3-SNAPSHOT" , true , BuildType . OPEN_SOURCE ,
203+ null , mockDependencyVersions (), null )
162204 .get ();
163205 assertThat (attributes ).containsEntry ("include-java" , "ROOT:example$java/org/springframework/boot/docs" );
164206 assertThat (attributes ).containsEntry ("url-spring-data-cassandra-site" ,
0 commit comments