This repository has been archived by the owner on Feb 3, 2025. It is now read-only.
forked from akhikhl/gretty
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
89 lines (75 loc) · 2.53 KB
/
build.gradle
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
buildscript {
project.ext {
if(has('privateRepoDir')) {
privateRepoDir = privateRepoDir instanceof File ? privateRepoDir.path : privateRepoDir.toString()
if(!new File(privateRepoDir).isAbsolute())
privateRepoDir = new File(projectDir, privateRepoDir).canonicalPath
} else
privateRepoDir = new File(project.buildDir, 'privateRepo').canonicalPath
}
repositories {
maven {
url "file:$privateRepoDir"
}
mavenCentral()
}
dependencies {
classpath 'org.apache.commons:commons-lang3:3.4'
}
}
plugins {
id 'base'
id 'maven-publish'
}
ext {
project_website = "https://github.com/${developerId}/${projectId}"
vcs_url = "${project_website}.git"
project_scm = "scm:git@github.com:${developerId}/${projectId}.git"
license_url = "https://raw.github.com/${developerId}/${projectId}/master/LICENSE"
//privateRepoDir="~/Desktop/private"
}
task('buildIntegrationTests', type: GradleBuild) {
dir = file('integrationTests')
tasks = [ 'build' ]
project.tasks.build.finalizedBy it
onlyIf { !project.tasks.build.getState().getFailure() }
}
task('testAll', dependsOn: tasks.build)
task('testAllIntegrationTests', type: GradleBuild) {
dependsOn buildIntegrationTests
dir = file('integrationTests')
tasks = [ 'testAll' ]
project.tasks.testAll.finalizedBy it
onlyIf { !project.tasks.testAll.getState().getFailure() }
}
task('cleanIntegrationTests', type: GradleBuild) {
dir = file('integrationTests')
tasks = [ 'clean' ]
project.tasks.clean.dependsOn it
}
task('wrapper', type: Wrapper) {
gradleVersion = '2.14.1'
}
gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
// This won't find any publishToMavenLocal tasks. Those are of type PublishToMavenLocal
Collection<Task> mavenPublishTasks = taskGraph.allTasks.findAll { it instanceof PublishToMavenRepository }
if (!mavenPublishTasks) {
return // We're not running any tasks that publish to a (remote) Maven repo.
}
Closure nexusCredentials = {
username = getPropertyOrFailBuild 'nexus.username'
password = getPropertyOrFailBuild 'nexus.password'
}
mavenPublishTasks.each {
if (!it.name.contains("publishToPrivateRepository") && !it.name.contains("publishMavenJavaPublicationToPrivateRepository")) {
it.repository.credentials nexusCredentials
}
}
}
String getPropertyOrFailBuild(String key) {
if (!rootProject.hasProperty(key)) {
throw new GradleException("You must define the '$key' property in order to publish to Nexus.")
} else {
rootProject.property(key) as String
}
}