-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
175 lines (150 loc) · 4.72 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
plugins {
id 'java'
id 'maven-publish'
id 'com.enonic.defaults' version '2.1.5'
id 'com.enonic.xp.base' version '3.4.0'
id "com.github.node-gradle.node" version '7.0.2'
}
apply from: "$rootDir/gradle/env.gradle"
apply from: "$rootDir/gradle/node.gradle"
configurations {
devResources {
attributes {
attribute( LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named( LibraryElements, 'dev-resources' ) )
}
}
}
repositories {
mavenCentral()
xp.enonicRepo()
}
group = 'com.enonic.lib'
archivesBaseName = 'lib-admin-ui'
node {
download = true
version = '20.13.1'
}
publishing {
publications {
mavenJava( MavenPublication ) {
pom {
name = 'Enonic Admin UI Library'
description = 'UI components for Enonic XP applications'
url = 'https://github.com/enonic/lib-admin-ui'
licenses {
license {
name = 'GNU General Public License v3.0'
url = 'https://github.com/enonic/lib-admin-ui/blob/master/LICENSE.txt'
}
}
developers {
developer {
id = 'developers'
name = 'Enonic developers'
email = 'developers@enonic.com'
}
}
scm {
connection = 'scm:git:https://github.com/enonic/lib-admin-ui.git'
developerConnection = 'scm:git:git@github.com:enonic/lib-admin-ui.git'
url = 'https://github.com/enonic/lib-admin-ui'
}
}
}
}
}
loadConfiguration()
tasks.register( 'lint', NpmTask ) {
dependsOn npmInstall
args = ['run', 'lint']
outputs.upToDateWhen { false }
}
check.dependsOn( lint )
tasks.register( 'typescript', NpmTask ) {
dependsOn npmInstall
description = 'Build JS and DTS'
def buildEnv = isProd() ? 'prod' : 'dev'
environment = ['NODE_ENV': nodeEnvironment()]
args = ['run', "build:$buildEnv"]
inputs.dir 'src/main/resources/assets/admin/common'
outputs.dirs( "$buildDir/tmp/src/main/resources/assets/admin/common/js",
"$buildDir/resources/main/dev/lib-admin-ui",
"$buildDir/resources/main/assets/admin/common" )
}
tasks.register( 'copyJS', Copy ) {
dependsOn typescript
if ( !isProd() )
{
from "$buildDir/tmp/src/main/resources/assets/admin/common/js"
into "$buildDir/resources/main/dev/lib-admin-ui"
includeEmptyDirs false
}
inputs.dir "$buildDir/tmp/src/main/resources/assets/admin/common/js"
outputs.dir "$buildDir/resources/main/dev/lib-admin-ui"
}
tasks.register( 'copyPackage', Copy ) {
dependsOn typescript
from( './' ) {
include 'package.json'
}
into "$buildDir/resources/main/dev/lib-admin-ui"
includeEmptyDirs false
inputs.file "./package.json"
outputs.file "$buildDir/resources/main/dev/lib-admin-ui/package.json"
}
jar {
exclude 'dev/**'
exclude 'assets/spec/**'
exclude 'assets/**/*.ts'
exclude 'assets/**/*.less'
exclude 'assets/**/styles/*.js'
exclude 'assets/**/icons/*.txt'
// COMMON/LIB excludes
// Exclude complex files, that only present after the first build and must be evaluated dynamically
def whitelist = [
/.*lib\.js$/,
/.*\.css$/,
] as List
if (isProd()) {
exclude '**/*.map'
}
else
{
whitelist.add( /.*\.map$/ )
}
exclude { FileTreeElement el ->
!el.directory && el.relativePath.contains( 'common/lib' ) && ( !whitelist.any { re -> el.relativePath.toString().matches( re ) } )
}
includeEmptyDirs = false
dependsOn copyJS
dependsOn copyPackage
}
tasks.register( 'devJar', Jar ) {
archiveClassifier = 'dev-resources'
from sourceSets.main.output
include 'dev/**'
exclude 'dev/lib-admin-ui/lib.js'
includeEmptyDirs = false
dependsOn copyJS
dependsOn copyPackage
}
tasks.assemble.dependsOn devJar
artifacts {
devResources devJar
}
components.java.addVariantsFromConfiguration( configurations.devResources ) {
}
tasks.register( 'flush', Delete ) {
dependsOn clean
description = 'Clean the project from built sources and dependencies'
delete '.xp'
}
def loadConfiguration() {
def envList = [ 'dev', 'prod' ]
def environment = hasEnvironment() ? env : 'prod'
if ( !envList.contains( environment ) ) {
def message = "Target environment '$environment' is not allowed. Please use one of the following: ${envList.join(", ")}"
throw new ResourceException( message )
}
println "Environment is set to $nodeEnvironment"
}