@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2012 - 20 19 the original author or authors .
* Copyright 2012 - 20 20 the original author or authors .
*
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -17,6 +17,7 @@
package org.springframework.boot.maven ;
package org.springframework.boot.maven ;
import java.io.File ;
import java.io.File ;
import java.io.IOException ;
import java.util.Arrays ;
import java.util.Arrays ;
import java.util.Collections ;
import java.util.Collections ;
import java.util.LinkedHashSet ;
import java.util.LinkedHashSet ;
@ -131,4 +132,20 @@ class ArtifactsLibrariesTests {
assertThat ( this . libraryCaptor . getAllValues ( ) . get ( 1 ) . getName ( ) ) . isEqualTo ( "g2-artifact-1.0.jar" ) ;
assertThat ( this . libraryCaptor . getAllValues ( ) . get ( 1 ) . getName ( ) ) . isEqualTo ( "g2-artifact-1.0.jar" ) ;
}
}
@Test
void libraryCoordinatesVersionUsesBaseVersionOfArtifact ( ) throws IOException {
Artifact snapshotArtifact = mock ( Artifact . class ) ;
given ( snapshotArtifact . getType ( ) ) . willReturn ( "jar" ) ;
given ( snapshotArtifact . getScope ( ) ) . willReturn ( "compile" ) ;
given ( snapshotArtifact . getGroupId ( ) ) . willReturn ( "g1" ) ;
given ( snapshotArtifact . getArtifactId ( ) ) . willReturn ( "artifact" ) ;
given ( snapshotArtifact . getVersion ( ) ) . willReturn ( "1.0-20200929.090327-28" ) ;
given ( snapshotArtifact . getBaseVersion ( ) ) . willReturn ( "1.0-SNAPSHOT" ) ;
given ( snapshotArtifact . getFile ( ) ) . willReturn ( new File ( "a" ) ) ;
given ( snapshotArtifact . getArtifactHandler ( ) ) . willReturn ( this . artifactHandler ) ;
this . artifacts = Collections . singleton ( snapshotArtifact ) ;
new ArtifactsLibraries ( this . artifacts , null , mock ( Log . class ) ) . doWithLibraries (
( library ) - > assertThat ( library . getCoordinates ( ) . getVersion ( ) ) . isEqualTo ( "1.0-SNAPSHOT" ) ) ;
}
}
}