1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package cbt
import java.io.File
import java.net.URL
import java.nio.file.Files.readAllBytes
trait Publish extends PackageJars{
def description: String
def url: URL
def developers: Seq[Developer]
def licenses: Seq[License]
def scmUrl: String
def scmConnection: String
def inceptionYear: Int
def organization: Option[Organization]
// ========== package ==========
/** put additional xml that should go into the POM file in here */
def pom: File = lib.pom(
groupId = groupId,
artifactId = artifactId,
version = version,
scalaMajorVersion = scalaMajorVersion,
name = name,
description = description,
url = url,
developers = developers,
licenses = licenses,
scmUrl = scmUrl,
scmConnection = scmConnection,
inceptionYear,
organization,
dependencies = dependencies,
jarTarget = jarTarget
)
// ========== publish ==========
final protected def releaseFolder = s"/${groupId.replace(".","/")}/${artifactId}_$scalaMajorVersion/$version/"
private def snapshotUrl = new URL("https://oss.sonatype.org/content/repositories/snapshots")
private def releaseUrl = new URL("https://oss.sonatype.org/service/local/staging/deploy/maven2")
def publishUrl = if(version.endsWith("-SNAPSHOT")) snapshotUrl else releaseUrl
override def copy(context: Context) = super.copy(context).asInstanceOf[Publish]
protected def sonatypeCredentials = {
// FIXME: this should probably not use cbtHome, but some reference to the system's host cbt
new String(readAllBytes((context.cbtRootHome ++ "/sonatype.login").toPath)).trim
}
def publishSnapshot: Unit = {
copy( context.copy(version = Some(version+"-SNAPSHOT")) ).publishUnsigned
}
def publishUnsigned: Unit = {
lib.publishUnsigned(
sourceFiles, `package` :+ pom, publishUrl ++ releaseFolder, sonatypeCredentials
)
}
def publishSigned: Unit = {
lib.publishSigned(
sourceFiles, `package` :+ pom, publishUrl ++ releaseFolder, sonatypeCredentials
)
}
}
|