-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
150 lines (124 loc) · 4.11 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
plugins {
id 'java'
id 'eclipse'
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = '0.0.0-SNAPSHOT'
defaultTasks 'build'
dependencies {
compile 'com.untill:untill-driver-api2:14.0'
compile fileTree(dir: 'lib', include: '*.jar')
testCompile 'junit:junit:4.12'
}
repositories {
maven {
url 'https://dev.untill.com/artifactory/repo'
}
}
jar {
manifest.attributes(
'Specification-Title': project.name,
'Specification-Version': version.replaceAll(/-SNAPSHOT$/, ''),
'Implementation-Title': project.name,
'Implementation-Version': version,
'Main-Class': "${gradle.mainClassPackage}.${gradle.mainClassName}",
'Class-Path': '.',
)
}
configurations.archives.artifacts.removeAll { it.archiveTask.is jar }
task driverZip(type: Zip, dependsOn: jar) {
group = 'build'
description = 'assembles a zip archive'
from (jar.archivePath)
configurations.compile.resolvedConfiguration.resolvedArtifacts.each { artifact ->
if (artifact.name != 'untill-driver-api2') {
from (artifact.file)
}
}
from ('lib') {
include '**/*.jar'
}
}
artifacts {
archives driverZip
}
task driverFolder(type: Copy, dependsOn: jar) {
group = 'build'
description = 'assembles driver folder'
from (jar.archivePath)
configurations.compile.resolvedConfiguration.resolvedArtifacts.each { artifact ->
if (artifact.name != 'untill-driver-api2') {
from (artifact.file)
}
}
from ('lib') {
include '**/*.jar'
}
into new File(project.distsDir, project.name)
}
build.dependsOn 'driverFolder'
if (!file('src').exists()) {
if (project.name == 'my-driver') throw new GradleException('Project name is not changed from default value')
if (gradle.mainClassPackage == 'com.mycompany.mypackage') throw new GradleException('Package is not changed from default value')
if (gradle.mainClassName == 'MyDriver') throw new GradleException('Class name is not changed from default value')
sourceSets.main.java.srcDirs.each { it.mkdirs() }
sourceSets.test.java.srcDirs.each { it.mkdirs() }
sourceSets.main.resources.srcDirs.each { it.mkdirs() }
sourceSets.test.resources.srcDirs.each { it.mkdirs() }
file('lib').mkdirs()
def packagePath = new File(sourceSets.main.java.srcDirs[0], gradle.mainClassPackage.replace('.', '/'))
packagePath.mkdirs()
new File(packagePath, gradle.mainClassName + '.java').write """\
package ${gradle.mainClassPackage};
import java.util.ArrayList;
import java.util.Map;
import com.untill.driver.IDriver;
import com.untill.driver.IDriverContext;
import com.untill.driver.interfaces.IDriverInterface;
import com.untill.driver.params.DriverParam;
import com.untill.driver.params.ParamType;
public class ${gradle.mainClassName} implements IDriver {
public static final String PARAM_URL = "url";
public static final String PARAM_URL_DEFAULT = "https://127.0.0.1:7777";
public static final String PARAM_USER = "user";
public static final String PARAM_PASSWORD = "password";
@Override
public ArrayList<DriverParam> getParamsList() {
// TODO add real driver parameters. A code below is just an example
return DriverParam.list(
new DriverParam.Builder().key(PARAM_URL).title("Platform Address")
.type(ParamType.STRING).defaultValue(PARAM_URL_DEFAULT).mandatory(true).build(),
new DriverParam.Builder().key(PARAM_USER).title("User")
.type(ParamType.STRING).mandatory(true).build(),
new DriverParam.Builder().key(PARAM_PASSWORD).title("Password")
.type(ParamType.STRING).mandatory(true).build()
);
}
@Override
public String getDriverName() {
return "Foo Driver";
}
@Override
public String getProviderName() {
return "My Company";
}
@Override
public String getVersion() {
return this.getClass().getPackage().getImplementationVersion();
}
@Override
public Map<Class<? extends IDriverInterface>, IDriverInterface> init(IDriverContext context) {
/*
* TODO init & return interfaces, example:
* return DriverInterfaces.map(IEft, FooEft);
*/
return null;
}
@Override
public void finit() {
// TODO Release resources, etc
}
}
""".stripIndent()
}