forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
83 lines (70 loc) · 3.38 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
buildscript {
dependencies {
classpath 'org.jsoup:jsoup:1.13.1'
}
}
plugins {
id 'application'
id 'airbyte-docker'
}
import org.jsoup.Jsoup;
dependencies {
implementation project(':airbyte-db:db-lib')
implementation project(':airbyte-api')
implementation project(':airbyte-connector-test-harnesses:acceptance-test-harness')
implementation project(':airbyte-config:config-models')
implementation libs.airbyte.protocol
implementation 'org.mockito:mockito-core:4.6.1'
implementation 'net.sourceforge.argparse4j:argparse4j:0.8.1'
runtimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
implementation 'org.junit.platform:junit-platform-launcher:1.7.0'
implementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
implementation 'org.junit.jupiter:junit-jupiter-params:5.8.1'
}
def getFullPath(String className) {
def matchingFiles = project.fileTree("src/main/java")
.filter { file -> file.getName().equals("${className}.java".toString()) }.asCollection()
if (matchingFiles.size() == 0) {
throw new IllegalArgumentException("Ambiguous class name ${className}: no file found.")
}
if (matchingFiles.size() > 1) {
throw new IllegalArgumentException("Ambiguous class name ${className}: more than one matching file was found. Files found: ${matchingFiles}")
}
def absoluteFilePath = matchingFiles[0].toString()
def pathInPackage = project.relativePath(absoluteFilePath.toString()).replaceAll("src/main/java/", "").replaceAll("\\.java", "")
return pathInPackage
}
task generateSourceTestDocs(type: Javadoc) {
def javadocOutputDir = project.file("${project.buildDir}/docs/javadoc")
options.addStringOption('Xdoclint:none', '-quiet')
classpath = sourceSets.main.runtimeClasspath
source = sourceSets.main.allJava
destinationDir = javadocOutputDir
doLast {
def className = "SourceAcceptanceTest"
// this can be made into a list once we have multiple standard tests, and can also be used for destinations
def pathInPackage = getFullPath(className)
def stdSrcTest = project.file("${javadocOutputDir}/${pathInPackage}.html").readLines().join("\n")
def methodList = Jsoup.parse(stdSrcTest).body().select("section.methodDetails>ul>li>section")
def md = ""
for (methodInfo in methodList) {
def annotations = methodInfo.select(".memberSignature>.annotations").text()
if (!annotations.contains("@Test")) {
continue
}
def methodName = methodInfo.selectFirst("div>span.memberName").text()
def methodDocstring = methodInfo.selectFirst("div.block")
md += "## ${methodName}\n\n"
md += "${methodDocstring != null ? methodDocstring.text().replaceAll(/([()])/, '\\\\$1') : 'No method description was provided'}\n\n"
}
def outputDoc = new File("${rootDir}/docs/connector-development/testing-connectors/standard-source-tests.md")
outputDoc.write "# Standard Source Test Suite\n\n"
outputDoc.append "Test methods start with `test`. Other methods are internal helpers in the java class implementing the test suite.\n\n"
outputDoc.append md
}
outputs.upToDateWhen { false }
}
project.build.dependsOn(generateSourceTestDocs)
application {
mainClass = 'io.airbyte.integrations.standardtest.source.PythonSourceAcceptanceTest'
}