1 /*
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 plugins {
25 id 'org.openjdk.skara.gradle.proxy'
26 id 'org.openjdk.skara.gradle.version'
27 id 'org.openjdk.skara.gradle.reproduce'
28 }
29
30 configure(subprojects.findAll() { it.name != 'bots' }) {
31 apply plugin: 'java-library'
32 apply plugin: 'maven-publish'
33 apply plugin: 'org.openjdk.skara.gradle.module'
34 apply plugin: 'org.openjdk.skara.gradle.version'
35
36 group = 'org.openjdk.skara'
37
38 repositories {
39 mavenLocal()
40 maven {
41 url System.getProperty('maven.url', 'https://repo.maven.apache.org/maven2/')
42 }
43 }
44
45 dependencies {
46 testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
47 testImplementation 'org.junit.jupiter:junit-jupiter-params:5.3.1'
48 testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
49 }
50
51 test {
52 useJUnitPlatform()
53
54 if (findProperty('credentials')) {
55 systemProperty "credentials", findProperty('credentials')
56 }
57
58 testLogging {
59 events "passed", "skipped", "failed"
60 }
61 }
62
63 publishing {
64 repositories {
65 maven {
66 url = findProperty('mavenRepositoryUrl')
67 credentials {
68 username = findProperty('mavenRepositoryUser')
69 password = findProperty('mavenRepositoryPassword')
70 }
71 }
72 }
73 }
74
75 gradle.taskGraph.whenReady { graph ->
76 if (graph.hasTask(publish) && !findProperty('mavenRepositoryUrl')) {
77 throw new GradleException("To publish artifacts, set the maven repository url -PmavenRepositoryUrl=<url>")
78 }
79 if (graph.hasTask(publish) && !findProperty('mavenRepositoryUser')) {
80 throw new GradleException("To publish artifacts, set the maven repository user name -PmavenRepositoryUser=<user>")
81 }
82 if (graph.hasTask(publish) && !findProperty('mavenRepositoryPassword')) {
83 throw new GradleException("To publish artifacts, set the maven repository password -PmavenRepositoryPassword=<password>")
84 }
85 }
86 }
87
88 task jar {
89 subprojects.findAll() { it.name != 'bots' }.each { dependsOn "${it.path}:jar" }
90 }
91
92 task test {
93 subprojects.findAll() { it.name != 'bots' }.each { dependsOn "${it.path}:test" }
94 }
95
96 reproduce {
97 dockerfile = 'test.dockerfile'
98 }
99
100 task deleteBuildDir(type: Delete) {
101 delete project.buildDir
102 }
103
104 task local(type: Copy) {
105 def os = System.getProperty('os.name').toLowerCase()
106 def osName = os.startsWith('win') ? 'Windows' :
107 os.startsWith('mac') ? 'Macos' : 'Linux'
108
109 dependsOn ':cli:image' + osName
110 dependsOn deleteBuildDir
111 from zipTree(file(project.rootDir.toString() +
112 '/cli/build/distributions/cli' +
113 '-' + project.version + '-' +
114 osName.toLowerCase() + '.zip'))
115 into project.buildDir
116 }
117
118 defaultTasks 'local'