forked from getsentry/sentry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.kts
More file actions
92 lines (80 loc) · 3.46 KB
/
Copy pathrelease.kts
File metadata and controls
92 lines (80 loc) · 3.46 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* Outputs the bash script that uploads packages to Bintray.
*
* This script assumes that all distrbution packages have been downloaded and unzipped in one directory.
* For example, all packages are in the "dist" directory:
*
* dist
* ├── sentry-3.1.2-SNAPSHOT
* ├── sentry-android-3.1.2-SNAPSHOT
* ├── sentry-android-core-3.1.2-SNAPSHOT
* ├── sentry-android-ndk-3.1.2-SNAPSHOT
* ├── sentry-android-timber-3.1.2-SNAPSHOT
* ├── sentry-log4j2-3.1.2-SNAPSHOT
* ├── sentry-logback-3.1.2-SNAPSHOT
* ├── sentry-servlet-3.1.2-SNAPSHOT
* ├── sentry-spring-3.1.2-SNAPSHOT
* └── sentry-spring-boot-starter-3.1.2-SNAPSHOT
*
* To execute the script two environment variables that are used by Maven have to be present: BINTRAY_USERNAME, BINTRAY_API_KEY
*
* Example usage (assuming that the script is executed from the `<project-root>/scripts` directory and the distribution files are in `<project-root>/dist`):
* $ kotlinc -script release.kts -- -d ../dist -javaRepositoryUrl https://api.bintray.com/maven/sentry/sentry-java/sentry-java/ -androidRepositoryUrl https://api.bintray.com/maven/sentry/sentry-android/sentry-java/ | sh
*
*/
import java.io.File
/**
* Path to a directory with unzipped distribution packages.
*/
val path = argOrDefault("d", ".")
/**
* Path to Maven settings.xml containing bintray username and api key.
*/
val settingsPath = argOrDefault("s", "./settings.xml")
/**
* Bintray repository URL for non-Android projects.
*/
val javaRepositoryUrl = requiredArg("javaRepositoryUrl")
/**
* Bintray repository URL for Android projects.
*/
val androidRepositoryUrl = requiredArg("androidRepositoryUrl")
/**
* Maven server id in the settings.xml file.
*/
val repositoryId = argOrDefault("repositoryId", "bintray")
/**
* If package should be published on bintray or just uploaded but not published.
*/
val publish = if (argOrDefault("publish", "false") == "true") 1 else 0
File(path)
.listFiles { file -> file.isDirectory() }
.forEach { folder ->
val path = folder.path
val module = folder.name
val file: String
val repositoryUrl: String
val androidFile = folder.listFiles { it -> it.name.contains("release") && it.extension == "aar" }.firstOrNull()
if (androidFile != null) {
file = androidFile.path
repositoryUrl = androidRepositoryUrl
} else {
file = "$path/$module.jar"
repositoryUrl = javaRepositoryUrl
}
val javadocFile = "$path/$module-javadoc.jar"
val sourcesFile = "$path/$module-sources.jar"
val pomFile = "$path/pom-default.xml"
val command = "./mvnw deploy:deploy-file -Dfile=$file -Dfiles=$javadocFile,$sourcesFile -Dclassifiers=sources,javadoc -Dtypes=jar,jar -DpomFile=$pomFile -DrepositoryId=$repositoryId -Durl=$repositoryUrl\\;publish\\=$publish --settings $settingsPath"
println(command)
}
/**
* Returns the value for a command line argument passed with -argName flag or throws an exception if not provided.
*/
fun Release.requiredArg(argName: String) =
if (args.contains("-$argName")) args[1 + args.indexOf("-$argName")] else throw Error("$argName parameter must be provided")
/**
* Returns the value for a command line argument passed with -argName flag or returns the default value.
*/
fun Release.argOrDefault(argName: String, default: String) =
if (args.contains("-$argName")) args[1 + args.indexOf("-$argName")] else default