-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
89 lines (78 loc) · 2.31 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
plugins {
id 'java' // Used for creating jars.
id 'maven-publish' // Adds newer `publish` task and other stuff.
id 'com.github.node-gradle.node' version '5.0.0' // Used for executing node scripts.
}
group 'org.otasyn.template'
version '0.1.0-SNAPSHOT'
ext {
/* Determine if working with a snapshot. */
isSnapshot = version.endsWith('SNAPSHOT')
/* The path in which generated files will be stored. */
webjarPath = "webjars/${archivesBaseName}/${project.version}/"
}
node {
/* https://github.com/srs/gradle-node-plugin/blob/master/docs/node.md#configuring-the-plugin */
download = false
}
/**
* If npm_install is running slow, check the npm config. It should be:
* package-lock=true
*/
task npmBuild(type: NpmTask) {
dependsOn npmInstall
args = ['run', 'build', '--', "--deploy-url=${webjarPath}"]
if (!isSnapshot) {
args << '--prod'
}
}
build.dependsOn npmBuild
/**
* Gather the built sources and package them into a JAR file.
*/
jar {
dependsOn npmBuild
if (isSnapshot) {
from 'dist/angular-webjar/snapshot'
} else {
from 'dist/angular-webjar/production'
}
into "META-INF/resources/${webjarPath}"
}
/**
* Instead of using `install` task, now use `publish`, `publishToMavenLocal`, etc.
*/
publishing {
publications {
/**
* Custom PubName of `angularWebjar` will produce custom tasks:
* `publishAngularWebjarPublicationToMavenLocal`
* `publishAngularWebjarPublicationToTemplateRepoRepository`
*/
angularWebjar(MavenPublication) {
from components.java
}
}
repositories {
/**
* The URL and credentials should be stored in
* `$USER_HOME/.gradle/gradle.properties` or
* or other gradle properties location.
*/
if (project.hasProperty('repoUrl') && repoUrl) {
maven {
/* Will be used for creating the publish method. */
name 'TemplateRepo'
/* The URLs for release and snapshot repos. */
def releasesRepoUrl = "${repoUrl}/maven-releases/"
def snapshotsRepoUrl = "${repoUrl}/maven-snapshots/"
/* Determine if the build is a snapshot or release and set the URL accordingly. */
url = isSnapshot ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username "${repoUsername}"
password "${repoPassword}"
}
}
}
}
}