Skip to content

Commit b57a951

Browse files
author
ehennum
committed
renaming of properties #966
1 parent 985b70b commit b57a951

File tree

10 files changed

+96
-96
lines changed

10 files changed

+96
-96
lines changed

marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/fnclassgen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fun main(args: Array<String>) {
2121
if (args.size === 2) {
2222
Generator().serviceBundleToJava(args[0], args[1])
2323
} else {
24-
System.err.println("usage: fnclassgen servFilename javaBaseDir")
24+
System.err.println("usage: fnclassgen serviceDeclarationFile javaBaseDir")
2525
System.exit(-1)
2626
}
2727
}

marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/fnmodinit.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import com.marklogic.client.tools.proxy.Generator
1919

2020
fun main(args: Array<String>) {
2121
if (args.size === 2) {
22-
Generator().declarationToModuleStubImpl(args[0], args[1])
22+
Generator().endpointDeclToModStubImpl(args[0], args[1])
2323
} else {
24-
System.err.println("usage: fnmodinit functionFilename moduleExtension")
24+
System.err.println("usage: fnmodinit endpointDeclarationFile moduleExtension")
2525
System.exit(-1)
2626
}
2727
}

marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/gradle/ProxyConfig.kt renamed to marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/gradle/EndpointProxiesConfig.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package com.marklogic.client.tools.gradle
1717

18-
class ProxyConfig {
19-
var serviceBundleFilename : String = ""
20-
var javaBaseDirectory : String = ""
18+
class EndpointProxiesConfig {
19+
var serviceDeclarationFile : String = ""
20+
var javaBaseDirectory : String = ""
2121
}

marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/gradle/GeneratorTask.kt renamed to marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/gradle/EndpointProxiesGenTask.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@ import org.gradle.api.DefaultTask
2020
import org.gradle.api.tasks.TaskAction
2121

2222
// TODO: declare outputs
23-
open class GeneratorTask : DefaultTask() {
23+
open class EndpointProxiesGenTask : DefaultTask() {
2424
val generator = Generator()
2525

26-
var serviceBundleFilename: String = ""
27-
var javaBaseDirectory: String = ""
26+
var serviceDeclarationFile: String = ""
27+
var javaBaseDirectory: String = ""
2828

2929
@TaskAction
3030
fun serviceBundleToJava() {
31-
val proxyConfig = project.property("proxyConfig") as ProxyConfig
32-
if (serviceBundleFilename == "") {
33-
if (proxyConfig.serviceBundleFilename != "") {
34-
serviceBundleFilename = proxyConfig.serviceBundleFilename
35-
} else if (project.hasProperty("serviceBundleFilename")) {
36-
serviceBundleFilename = project.property("serviceBundleFilename") as String
31+
val proxiesConfig = project.property("endpointProxiesConfig") as EndpointProxiesConfig
32+
if (serviceDeclarationFile == "") {
33+
if (proxiesConfig.serviceDeclarationFile != "") {
34+
serviceDeclarationFile = proxiesConfig.serviceDeclarationFile
35+
} else if (project.hasProperty("serviceDeclarationFile")) {
36+
serviceDeclarationFile = project.property("serviceDeclarationFile") as String
3737
} else {
38-
throw IllegalArgumentException("serviceBundleFilename not specified")
38+
throw IllegalArgumentException("serviceDeclarationFile not specified")
3939
}
4040
}
4141
if (javaBaseDirectory == "") {
42-
if (proxyConfig.javaBaseDirectory != "") {
43-
javaBaseDirectory = proxyConfig.javaBaseDirectory
42+
if (proxiesConfig.javaBaseDirectory != "") {
43+
javaBaseDirectory = proxiesConfig.javaBaseDirectory
4444
} else if (project.hasProperty("javaBaseDirectory")) {
4545
javaBaseDirectory = project.property("javaBaseDirectory") as String
4646
} else {
4747
javaBaseDirectory = project.projectDir.resolve("src/main/java").path
4848
}
4949
}
5050

51-
generator.serviceBundleToJava(serviceBundleFilename, javaBaseDirectory)
51+
generator.serviceBundleToJava(serviceDeclarationFile, javaBaseDirectory)
5252
}
5353
}

marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/gradle/ModuleInitTask.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ import org.gradle.api.tasks.TaskAction
2222
open class ModuleInitTask : DefaultTask() {
2323
val generator = Generator()
2424

25-
var functionFile: String = ""
26-
var moduleExtension: String = ""
25+
var endpointDeclarationFile: String = ""
26+
var moduleExtension: String = ""
2727

2828
@TaskAction
2929
fun declarationToModuleStub() {
30-
if (functionFile == "") {
31-
if (project.hasProperty("functionFile")) {
32-
functionFile = project.property("functionFile") as String
30+
if (endpointDeclarationFile == "") {
31+
if (project.hasProperty("endpointDeclarationFile")) {
32+
endpointDeclarationFile = project.property("endpointDeclarationFile") as String
3333
} else {
34-
throw IllegalArgumentException("functionFile not specified")
34+
throw IllegalArgumentException("endpointDeclarationFile not specified")
3535
}
3636
}
3737
if (moduleExtension== "") {
@@ -42,6 +42,6 @@ open class ModuleInitTask : DefaultTask() {
4242
}
4343
}
4444

45-
generator.declarationToModuleStubImpl(functionFile, moduleExtension)
45+
generator.endpointDeclToModStubImpl(endpointDeclarationFile, moduleExtension)
4646
}
4747
}

marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/gradle/ToolsPlugin.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import org.gradle.api.Project
2121
open class ToolsPlugin : Plugin<Project> {
2222
override fun apply(project: Project) {
2323

24-
project.extensions.add("proxyConfig", ProxyConfig())
24+
project.extensions.add("endpointProxiesConfig", EndpointProxiesConfig())
2525

26-
project.tasks.create("generateProxy", GeneratorTask::class.java)
27-
project.tasks.create("initializeModule", ModuleInitTask::class.java)
26+
project.tasks.create("generateEndpointProxies", EndpointProxiesGenTask::class.java)
27+
project.tasks.create("initializeModule", ModuleInitTask::class.java)
2828
}
2929
}

marklogic-development-tools/src/main/kotlin/com/marklogic/client/tools/proxy/Generator.kt

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -233,33 +233,33 @@ class Generator {
233233
}
234234
return mapping
235235
}
236-
fun serviceBundleToJava(servFilename: String, javaBaseDir: String) {
236+
fun serviceBundleToJava(servDeclFilename: String, javaBaseDir: String) {
237237
val warnings = mutableListOf<String>()
238238
val mapper = jacksonObjectMapper()
239239

240-
val servFile = File(servFilename)
241-
val servdef = mapper.readValue<ObjectNode>(servFile)
240+
val servDeclFile = File(servDeclFilename)
241+
val servdef = mapper.readValue<ObjectNode>(servDeclFile)
242242

243243
var endpointDirectory = servdef.get("endpointDirectory")?.asText()
244244
if (endpointDirectory === null) {
245-
throw IllegalArgumentException("no endpointDirectory property in $servFilename")
245+
throw IllegalArgumentException("no endpointDirectory property in $servDeclFilename")
246246
} else if (endpointDirectory.length === 0) {
247-
throw IllegalArgumentException("empty endpointDirectory property in $servFilename")
247+
throw IllegalArgumentException("empty endpointDirectory property in $servDeclFilename")
248248
} else if (!endpointDirectory.endsWith("/")) {
249249
endpointDirectory = endpointDirectory+"/"
250250
}
251251

252252
val fullClassName = servdef.get("\$javaClass")?.asText()
253253
if (fullClassName === null) {
254-
throw IllegalArgumentException("no \$javaClass property in $servFilename")
254+
throw IllegalArgumentException("no \$javaClass property in $servDeclFilename")
255255
}
256256

257257
val moduleFiles = mutableMapOf<String, File>()
258-
val functionFiles = mutableMapOf<String, File>()
259-
servFile.parentFile.listFiles().forEach{file ->
258+
val endpointDeclFiles = mutableMapOf<String, File>()
259+
servDeclFile.parentFile.listFiles().forEach{file ->
260260
val basename = file.nameWithoutExtension
261261
when(file.extension) {
262-
"api" -> functionFiles[basename] = file
262+
"api" -> endpointDeclFiles[basename] = file
263263
"sjs", "xqy" ->
264264
if (!moduleFiles.containsKey(basename))
265265
moduleFiles[basename] = file
@@ -269,11 +269,11 @@ class Generator {
269269
}
270270
}
271271
val moduleRoots = moduleFiles.keys
272-
val functionRoots = functionFiles.keys
272+
val functionRoots = endpointDeclFiles.keys
273273
unpairedWarnings(warnings, moduleFiles, functionRoots,
274274
"endpoint main module without function declaration")
275275

276-
val funcdefs = functionFiles.filter{entry ->
276+
val funcdefs = endpointDeclFiles.filter{entry ->
277277
if (moduleRoots.contains(entry.key)) {
278278
true
279279
} else {
@@ -302,7 +302,7 @@ class Generator {
302302
else funcDecl.joinToString("")
303303

304304
val classSrc = generateServClass(
305-
servdef, endpointDirectory, servFilename, fullClassName, funcImports, funcDecls, funcSrc
305+
servdef, endpointDirectory, servDeclFilename, fullClassName, funcImports, funcDecls, funcSrc
306306
)
307307

308308
writeClass(servdef, fullClassName, classSrc, javaBaseDir)
@@ -324,7 +324,7 @@ class Generator {
324324
classFile.writeText(classSrc)
325325
}
326326
fun generateServClass(
327-
servdef: ObjectNode, endpointDirectory: String, servFilename: String,
327+
servdef: ObjectNode, endpointDirectory: String, servDeclFilename: String,
328328
fullClassName: String, funcImports: String, funcDecls: String, funcSrc: String
329329
): String {
330330
val packageName = fullClassName.substringBeforeLast(".")
@@ -632,22 +632,22 @@ ${funcDecls}
632632
return nextCardinality
633633
}
634634

635-
fun declarationToModuleStubImpl(functionFilename: String, moduleExtension: String) {
636-
if (functionFilename === null || functionFilename.length == 0) {
635+
fun endpointDeclToModStubImpl(endpointDeclFilename: String, moduleExtension: String) {
636+
if (endpointDeclFilename === null || endpointDeclFilename.length == 0) {
637637
throw IllegalArgumentException("null declaration file")
638638
}
639639

640-
val functionFile = File(functionFilename)
641-
if (!functionFile.exists()) {
642-
throw IllegalArgumentException("declaration file doesn't exist: "+functionFilename)
640+
val endpointDeclFile = File(endpointDeclFilename)
641+
if (!endpointDeclFile.exists()) {
642+
throw IllegalArgumentException("declaration file doesn't exist: "+endpointDeclFilename)
643643
}
644644

645645
if(moduleExtension != "sjs" && moduleExtension != "xqy") {
646646
throw IllegalArgumentException("invalid module extension: "+moduleExtension)
647647
}
648648

649-
val moduleFile = functionFile.parentFile.resolve(
650-
functionFile.nameWithoutExtension+"."+moduleExtension
649+
val moduleFile = endpointDeclFile.parentFile.resolve(
650+
endpointDeclFile.nameWithoutExtension+"."+moduleExtension
651651
)
652652
if (moduleFile.exists()) {
653653
throw IllegalArgumentException("module file already exists: "+moduleFile.absolutePath)
@@ -658,7 +658,7 @@ ${funcDecls}
658658
val atomicTypes = getAtomicDataTypes()
659659
val documentTypes = getDocumentDataTypes()
660660

661-
val funcdef = mapper.readValue<ObjectNode>(functionFile)
661+
val funcdef = mapper.readValue<ObjectNode>(endpointDeclFile)
662662
val funcParams = funcdef.withArray("params")
663663

664664
val funcReturn = funcdef.get("return")
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.io.File;
2626
import java.io.IOException;
2727

28-
public class GeneratorTaskTest {
28+
public class EndpointProxiesGenTaskTest {
2929
@Rule
3030
public TemporaryFolder testDir = new TemporaryFolder();
3131

@@ -74,9 +74,9 @@ public void testTaskInit() throws IOException {
7474
.append("plugins {\n")
7575
.append(" id 'com.marklogic.client.tools'\n")
7676
.append("}\n")
77-
.append("task generateTestProxy(type: com.marklogic.client.tools.gradle.GeneratorTask) {\n")
78-
.append(" serviceBundleFilename = '"+testEnv.serviceDir.getPath()+"/service.json'\n")
79-
.append(" javaBaseDirectory = '"+testEnv.javaBaseDir.getPath()+"'\n")
77+
.append("task generateTestProxy(type: com.marklogic.client.tools.gradle.EndpointProxiesGenTask) {\n")
78+
.append(" serviceDeclarationFile = '"+testEnv.serviceDir.getPath()+"/service.json'\n")
79+
.append(" javaBaseDirectory = '"+testEnv.javaBaseDir.getPath()+"'\n")
8080
.append("}\n");
8181
writeBuildFile(buildText);
8282

@@ -108,9 +108,9 @@ public void testCommandLineInit() throws IOException {
108108
.withProjectDir(testDir.getRoot())
109109
.withPluginClasspath()
110110
.withArguments(
111-
"-PserviceBundleFilename="+testEnv.serviceDir.getPath()+"/service.json",
111+
"-PserviceDeclarationFile="+testEnv.serviceDir.getPath()+"/service.json",
112112
"-PjavaBaseDirectory="+testEnv.javaBaseDir.getPath(),
113-
"generateProxy"
113+
"generateEndpointProxies"
114114
)
115115
.withDebug(true)
116116
.build();
@@ -131,7 +131,7 @@ public void testPropertiesFile() throws IOException {
131131
writeBuildFile(fileText);
132132

133133
fileText = new StringBuilder()
134-
.append("serviceBundleFilename="+testEnv.serviceDir.getPath()+"/service.json\n")
134+
.append("serviceDeclarationFile="+testEnv.serviceDir.getPath()+"/service.json\n")
135135
.append("javaBaseDirectory="+testEnv.javaBaseDir.getPath()+"\n")
136136
.append("}\n");
137137
GradleTestUtil.writeTextFile(fileText.toString(), testEnv.propsFile);
@@ -140,7 +140,7 @@ public void testPropertiesFile() throws IOException {
140140
.create()
141141
.withProjectDir(testDir.getRoot())
142142
.withPluginClasspath()
143-
.withArguments("generateProxy")
143+
.withArguments("generateEndpointProxies")
144144
.withDebug(true)
145145
.build();
146146
assertTrue("config did not generate "+testEnv.outClass.getPath(), testEnv.outClass.exists());
@@ -159,9 +159,9 @@ public void testConfig() throws IOException {
159159
.append(" id 'com.marklogic.client.tools'\n")
160160
.append("}\n")
161161
.append("ext {\n")
162-
.append(" proxyConfig {\n")
163-
.append(" serviceBundleFilename = '"+testEnv.serviceDir.getPath()+"/service.json'\n")
164-
.append(" javaBaseDirectory = '"+testEnv.javaBaseDir.getPath()+"'\n")
162+
.append(" endpointProxiesConfig {\n")
163+
.append(" serviceDeclarationFile = '"+testEnv.serviceDir.getPath()+"/service.json'\n")
164+
.append(" javaBaseDirectory = '"+testEnv.javaBaseDir.getPath()+"'\n")
165165
.append(" }\n")
166166
.append("}\n");
167167
writeBuildFile(buildText);
@@ -170,7 +170,7 @@ public void testConfig() throws IOException {
170170
.create()
171171
.withProjectDir(testDir.getRoot())
172172
.withPluginClasspath()
173-
.withArguments("generateProxy")
173+
.withArguments("generateEndpointProxies")
174174
.withDebug(true)
175175
.build();
176176
assertTrue("config did not generate "+testEnv.outClass.getPath(), testEnv.outClass.exists());
@@ -187,8 +187,8 @@ public void testJavaDefault() throws IOException {
187187
.append("plugins {\n")
188188
.append(" id 'com.marklogic.client.tools'\n")
189189
.append("}\n")
190-
.append("task generateTestProxy(type: com.marklogic.client.tools.gradle.GeneratorTask) {\n")
191-
.append(" serviceBundleFilename = '"+testEnv.serviceDir.getPath()+"/service.json'\n")
190+
.append("task generateTestProxy(type: com.marklogic.client.tools.gradle.EndpointProxiesGenTask) {\n")
191+
.append(" serviceDeclarationFile = '"+testEnv.serviceDir.getPath()+"/service.json'\n")
192192
.append("}\n");
193193
writeBuildFile(buildText);
194194

marklogic-development-tools/src/test/java/com/marklogic/client/test/gradle/ModuleInitTaskTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public void runTaskInitTest(File apiFile, String modExtension, File buildFile, F
108108
.append(" id 'com.marklogic.client.tools'\n")
109109
.append("}\n")
110110
.append("task initModuleTest(type: com.marklogic.client.tools.gradle.ModuleInitTask) {\n")
111-
.append(" functionFile = '"+apiFile.getPath()+"'\n")
112-
.append(" moduleExtension = '"+modExtension+"'\n")
111+
.append(" endpointDeclarationFile = '"+apiFile.getPath()+"'\n")
112+
.append(" moduleExtension = '"+modExtension+"'\n")
113113
.append("}\n");
114114
writeBuildFile(buildText);
115115

@@ -139,7 +139,7 @@ public void runCommandLineInitTest(File apiFile, String modExtension, File build
139139
.withProjectDir(testDir.getRoot())
140140
.withPluginClasspath()
141141
.withArguments(
142-
"-PfunctionFile="+apiFile.getPath(),
142+
"-PendpointDeclarationFile="+apiFile.getPath(),
143143
"-PmoduleExtension="+modExtension,
144144
"initializeModule"
145145
)

0 commit comments

Comments
 (0)