1
1
package mill .scalalib .publish
2
2
3
- import mill .api .Ctx
3
+ import mill .api .{ Ctx , PathRef }
4
4
5
5
class LocalIvyPublisher (localIvyRepo : os.Path ) {
6
6
@@ -13,26 +13,26 @@ class LocalIvyPublisher(localIvyRepo: os.Path) {
13
13
ivy : os.Path ,
14
14
artifact : Artifact ,
15
15
extras : Seq [PublishInfo ]
16
- )(implicit ctx : Ctx .Log ): Unit =
17
- publishLocal(Some (jar), Some (sourcesJar), Some (docJar), pom, Right (ivy), artifact, extras)
16
+ )(implicit ctx : Ctx .Log ): Unit = {
17
+ val mainArtifacts = Seq (
18
+ LocalIvyPublisher .jarPublishInfo(jar),
19
+ LocalIvyPublisher .sourcesJarPublishInfo(sourcesJar),
20
+ LocalIvyPublisher .docJarPublishInfo(docJar)
21
+ )
22
+ publishLocal(pom, Right (ivy), artifact, mainArtifacts ++ extras)
23
+ }
18
24
19
25
/**
20
26
* Publishes a module locally
21
27
*
22
- * @param jar The JAR of this module, if it has one
23
- * @param sourcesJar The source JAR of this module, if it has one
24
- * @param docJar The javadoc JAR of this module, if it has one
25
28
* @param pom The POM of this module
26
29
* @param ivy If right, the path to the ivy.xml file of this module; if left, its content as a String
27
30
* @param artifact Coordinates of this module
28
- * @param extras Extra files to publish in this module
31
+ * @param extras Files to publish in this module
29
32
* @param ctx
30
33
* @return The files created or written to when publishing locally this module
31
34
*/
32
35
def publishLocal (
33
- jar : Option [os.Path ],
34
- sourcesJar : Option [os.Path ],
35
- docJar : Option [os.Path ],
36
36
pom : os.Path ,
37
37
ivy : Either [String , os.Path ],
38
38
artifact : Artifact ,
@@ -43,13 +43,10 @@ class LocalIvyPublisher(localIvyRepo: os.Path) {
43
43
val releaseDir = localIvyRepo / artifact.group / artifact.id / artifact.version
44
44
45
45
val toCopy : Seq [(Either [String , os.Path ], os.Path )] =
46
- jar.map(Right (_) -> releaseDir / " jars" / s " ${artifact.id}.jar " ).toSeq ++
47
- sourcesJar.map(Right (_) -> releaseDir / " srcs" / s " ${artifact.id}-sources.jar " ).toSeq ++
48
- docJar.map(Right (_) -> releaseDir / " docs" / s " ${artifact.id}-javadoc.jar " ).toSeq ++
49
- Seq (
50
- Right (pom) -> releaseDir / " poms" / s " ${artifact.id}.pom " ,
51
- ivy -> releaseDir / " ivys/ivy.xml"
52
- ) ++
46
+ Seq (
47
+ Right (pom) -> releaseDir / " poms" / s " ${artifact.id}.pom " ,
48
+ ivy -> releaseDir / " ivys/ivy.xml"
49
+ ) ++
53
50
extras.map { entry =>
54
51
(
55
52
Right (entry.file.path),
@@ -76,21 +73,39 @@ class LocalIvyPublisher(localIvyRepo: os.Path) {
76
73
ivy : os.Path ,
77
74
artifact : Artifact ,
78
75
extras : Seq [PublishInfo ]
79
- )(implicit ctx : Ctx .Log ): Seq [os.Path ] =
80
- publishLocal(
81
- Some (jar),
82
- Some (sourcesJar),
83
- Some (docJar),
84
- pom,
85
- Right (ivy),
86
- artifact,
87
- extras
76
+ )(implicit ctx : Ctx .Log ): Seq [os.Path ] = {
77
+ val mainArtifacts = Seq (
78
+ LocalIvyPublisher .jarPublishInfo(jar),
79
+ LocalIvyPublisher .sourcesJarPublishInfo(sourcesJar),
80
+ LocalIvyPublisher .docJarPublishInfo(docJar)
88
81
)
82
+ publishLocal(pom, Right (ivy), artifact, mainArtifacts ++ extras)
83
+ }
89
84
}
90
85
91
86
object LocalIvyPublisher
92
87
extends LocalIvyPublisher (
93
88
sys.props.get(" ivy.home" )
94
89
.map(os.Path (_))
95
90
.getOrElse(os.home / " .ivy2" ) / " local"
91
+ ) {
92
+
93
+ private [mill] def jarPublishInfo (jar : os.Path ): PublishInfo =
94
+ PublishInfo (PathRef (jar), ivyType = " jar" , ext = " jar" , ivyConfig = " compile" )
95
+ private [mill] def sourcesJarPublishInfo (sourcesJar : os.Path ): PublishInfo =
96
+ PublishInfo (
97
+ PathRef (sourcesJar),
98
+ ivyType = " src" ,
99
+ classifier = Some (" sources" ),
100
+ ext = " jar" ,
101
+ ivyConfig = " compile"
102
+ )
103
+ private [mill] def docJarPublishInfo (docJar : os.Path ): PublishInfo =
104
+ PublishInfo (
105
+ PathRef (docJar),
106
+ ivyType = " doc" ,
107
+ classifier = Some (" javadoc" ),
108
+ ext = " jar" ,
109
+ ivyConfig = " compile"
96
110
)
111
+ }
0 commit comments