mirror of
https://github.com/corda/corda.git
synced 2025-06-04 08:30:52 +00:00
CORDA-1280 - Update the api-scanner to the most recent version + regenerate api (#3154)
* Update v3 api scanner to most recent version * Regenerate api-current.txt * Fix bootstrapper classpath
This commit is contained in:
parent
d63ee71564
commit
181829a325
8046
.ci/api-current.txt
8046
.ci/api-current.txt
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
gradlePluginsVersion=3.2.0
|
gradlePluginsVersion=3.2.1
|
||||||
kotlinVersion=1.1.60
|
kotlinVersion=1.1.60
|
||||||
platformVersion=3
|
platformVersion=3
|
||||||
guavaVersion=21.0
|
guavaVersion=21.0
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package net.corda.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.TYPE;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||||
|
|
||||||
|
@Target({TYPE})
|
||||||
|
@Retention(CLASS)
|
||||||
|
@Inherited
|
||||||
|
public @interface AnAnnotation {
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package net.corda.core;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.TYPE;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||||
|
|
||||||
|
@Retention(CLASS)
|
||||||
|
@Target({TYPE})
|
||||||
|
public @interface DoNotImplement {
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
apply plugin: 'java-gradle-plugin'
|
apply plugin: 'java-gradle-plugin'
|
||||||
apply plugin: 'net.corda.plugins.publish-utils'
|
apply plugin: 'net.corda.plugins.publish-utils'
|
||||||
apply plugin: 'com.jfrog.artifactory'
|
apply plugin: 'com.jfrog.artifactory'
|
||||||
@ -20,8 +21,13 @@ gradlePlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
jacocoRuntime
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "io.github.lukehutch:fast-classpath-scanner:2.7.0"
|
compile "io.github.lukehutch:fast-classpath-scanner:2.18.2"
|
||||||
|
testCompile project(':api-scanner:annotations')
|
||||||
testCompile "org.assertj:assertj-core:$assertj_version"
|
testCompile "org.assertj:assertj-core:$assertj_version"
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
|
|
||||||
@ -29,13 +35,17 @@ dependencies {
|
|||||||
// on the Kotlin classes in the test/resources directory.
|
// on the Kotlin classes in the test/resources directory.
|
||||||
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||||
testCompile project(':api-scanner:annotations')
|
jacocoRuntime "org.jacoco:org.jacoco.agent:${jacoco.toolVersion}:runtime"
|
||||||
}
|
}
|
||||||
|
|
||||||
processTestResources {
|
processTestResources {
|
||||||
filesMatching('**/kotlin-*/build.gradle') {
|
filesMatching('**/kotlin-*/build.gradle') {
|
||||||
expand(['kotlin_version': kotlin_version])
|
expand(['kotlin_version': kotlin_version])
|
||||||
}
|
}
|
||||||
|
filesMatching('gradle.properties') {
|
||||||
|
expand(['jacocoAgent': configurations.jacocoRuntime.asPath.replace('\\', '/'),
|
||||||
|
'buildDir': buildDir])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publish {
|
publish {
|
||||||
|
@ -0,0 +1,128 @@
|
|||||||
|
package net.corda.plugins;
|
||||||
|
|
||||||
|
import io.github.lukehutch.fastclasspathscanner.scanner.ClassInfo;
|
||||||
|
import io.github.lukehutch.fastclasspathscanner.scanner.FieldInfo;
|
||||||
|
import io.github.lukehutch.fastclasspathscanner.scanner.MethodInfo;
|
||||||
|
import io.github.lukehutch.fastclasspathscanner.typesignature.TypeSignature;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.joining;
|
||||||
|
import static java.util.stream.Collectors.toCollection;
|
||||||
|
|
||||||
|
public class ApiPrintWriter extends PrintWriter {
|
||||||
|
ApiPrintWriter(File file, String encoding) throws FileNotFoundException, UnsupportedEncodingException {
|
||||||
|
super(file, encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void println(ClassInfo classInfo, int modifierMask, List<String> filteredAnnotations) {
|
||||||
|
append(asAnnotations(filteredAnnotations, ""));
|
||||||
|
append(Modifier.toString(classInfo.getClassRef().getModifiers() & modifierMask));
|
||||||
|
if (classInfo.isAnnotation()) {
|
||||||
|
/*
|
||||||
|
* Annotation declaration.
|
||||||
|
*/
|
||||||
|
append(" @interface ").print(classInfo.getClassName());
|
||||||
|
} else if (classInfo.isStandardClass()) {
|
||||||
|
/*
|
||||||
|
* Class declaration.
|
||||||
|
*/
|
||||||
|
append(" class ").print(classInfo.getClassName());
|
||||||
|
Set<ClassInfo> superclasses = classInfo.getDirectSuperclasses();
|
||||||
|
if (!superclasses.isEmpty()) {
|
||||||
|
append(" extends ").print(stringOf(superclasses));
|
||||||
|
}
|
||||||
|
Set<ClassInfo> interfaces = classInfo.getDirectlyImplementedInterfaces();
|
||||||
|
if (!interfaces.isEmpty()) {
|
||||||
|
append(" implements ").print(stringOf(interfaces));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Interface declaration.
|
||||||
|
*/
|
||||||
|
append(" interface ").print(classInfo.getClassName());
|
||||||
|
Set<ClassInfo> superinterfaces = classInfo.getDirectSuperinterfaces();
|
||||||
|
if (!superinterfaces.isEmpty()) {
|
||||||
|
append(" extends ").print(stringOf(superinterfaces));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void println(MethodInfo method, String indentation) {
|
||||||
|
append(asAnnotations(method.getAnnotationNames(), indentation));
|
||||||
|
append(indentation);
|
||||||
|
if (method.getModifiersStr() != null) {
|
||||||
|
append(method.getModifiersStr()).append(' ');
|
||||||
|
}
|
||||||
|
if (!method.isConstructor()) {
|
||||||
|
append(removeQualifierFromBaseTypes(method.getResultTypeStr())).append(' ');
|
||||||
|
}
|
||||||
|
append(method.getMethodName()).append('(');
|
||||||
|
LinkedList<String> paramTypes = method
|
||||||
|
.getTypeSignature()
|
||||||
|
.getParameterTypeSignatures()
|
||||||
|
.stream()
|
||||||
|
.map(ApiPrintWriter::removeQualifierFromBaseTypes)
|
||||||
|
.collect(toCollection(LinkedList::new));
|
||||||
|
//if parameter is varargs, remove the array [] qualifier and replace with ellipsis
|
||||||
|
if (method.isVarArgs() && !paramTypes.isEmpty()) {
|
||||||
|
String vararg = paramTypes.removeLast();
|
||||||
|
paramTypes.add(vararg.substring(0, vararg.length() - 2) + "...");
|
||||||
|
}
|
||||||
|
append(paramTypes.stream().collect(joining(", ")));
|
||||||
|
println(')');
|
||||||
|
}
|
||||||
|
|
||||||
|
public void println(FieldInfo field, String indentation) {
|
||||||
|
append(asAnnotations(field.getAnnotationNames(), indentation))
|
||||||
|
.append(indentation)
|
||||||
|
.append(field.getModifierStr())
|
||||||
|
.append(' ')
|
||||||
|
.append(removeQualifierFromBaseTypes(field.getTypeStr()))
|
||||||
|
.append(' ')
|
||||||
|
.append(field.getFieldName());
|
||||||
|
if (field.getConstFinalValue() != null) {
|
||||||
|
append(" = ");
|
||||||
|
if (field.getConstFinalValue() instanceof String) {
|
||||||
|
append('"').append(field.getConstFinalValue().toString()).append('"');
|
||||||
|
} else if (field.getConstFinalValue() instanceof Character) {
|
||||||
|
append('\'').append(field.getConstFinalValue().toString()).append('\'');
|
||||||
|
} else {
|
||||||
|
append(field.getConstFinalValue().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String asAnnotations(Collection<String> items, String indentation) {
|
||||||
|
if (items.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return items.stream().map(ApiPrintWriter::removePackageName).collect(joining(System.lineSeparator() + indentation + '@', indentation + "@", System.lineSeparator()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String removePackageName(String className) {
|
||||||
|
return className.substring(className.lastIndexOf('.') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String stringOf(Collection<ClassInfo> items) {
|
||||||
|
return items.stream().map(ClassInfo::getClassName).collect(joining(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String removeQualifierFromBaseTypes(String className) {
|
||||||
|
return className.replace("java.lang.", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String removeQualifierFromBaseTypes(TypeSignature typeSignature) {
|
||||||
|
return removeQualifierFromBaseTypes(typeSignature.toString());
|
||||||
|
}
|
||||||
|
}
|
@ -31,26 +31,35 @@ public class ScanApi extends DefaultTask {
|
|||||||
* The VARARG modifier for methods has the same value as the TRANSIENT modifier for fields.
|
* The VARARG modifier for methods has the same value as the TRANSIENT modifier for fields.
|
||||||
* Unfortunately, {@link Modifier#methodModifiers() methodModifiers} doesn't include this
|
* Unfortunately, {@link Modifier#methodModifiers() methodModifiers} doesn't include this
|
||||||
* flag, and so we need to add it back ourselves.
|
* flag, and so we need to add it back ourselves.
|
||||||
|
*
|
||||||
* @link https://docs.oracle.com/javase/specs/jls/se8/html/index.html
|
* @link https://docs.oracle.com/javase/specs/jls/se8/html/index.html
|
||||||
*/
|
*/
|
||||||
private static final int METHOD_MASK = Modifier.methodModifiers() | Modifier.TRANSIENT;
|
private static final int METHOD_MASK = Modifier.methodModifiers() | Modifier.TRANSIENT;
|
||||||
private static final int FIELD_MASK = Modifier.fieldModifiers();
|
private static final int FIELD_MASK = Modifier.fieldModifiers();
|
||||||
private static final int VISIBILITY_MASK = Modifier.PUBLIC | Modifier.PROTECTED;
|
private static final int VISIBILITY_MASK = Modifier.PUBLIC | Modifier.PROTECTED;
|
||||||
|
|
||||||
|
private static final String DONOTIMPLEMENT_ANNOTATION_NAME = "net.corda.core.DoNotImplement";
|
||||||
private static final String INTERNAL_ANNOTATION_NAME = ".CordaInternal";
|
private static final String INTERNAL_ANNOTATION_NAME = ".CordaInternal";
|
||||||
private static final String DEFAULT_INTERNAL_ANNOTATION = "net.corda.core" + INTERNAL_ANNOTATION_NAME;
|
private static final String DEFAULT_INTERNAL_ANNOTATION = "net.corda.core" + INTERNAL_ANNOTATION_NAME;
|
||||||
private static final Set<String> ANNOTATION_BLACKLIST;
|
private static final Set<String> ANNOTATION_BLACKLIST;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Set<String> blacklist = new LinkedHashSet<>();
|
Set<String> blacklist = new LinkedHashSet<>();
|
||||||
blacklist.add("kotlin.jvm.JvmField");
|
blacklist.add("kotlin.jvm.JvmField");
|
||||||
blacklist.add("kotlin.jvm.JvmOverloads");
|
blacklist.add("kotlin.jvm.JvmOverloads");
|
||||||
blacklist.add(DEFAULT_INTERNAL_ANNOTATION);
|
blacklist.add("kotlin.jvm.JvmStatic");
|
||||||
ANNOTATION_BLACKLIST = unmodifiableSet(blacklist);
|
blacklist.add("kotlin.jvm.JvmDefault");
|
||||||
|
blacklist.add("kotlin.Deprecated");
|
||||||
|
blacklist.add("java.lang.Deprecated");
|
||||||
|
blacklist.add(DEFAULT_INTERNAL_ANNOTATION);
|
||||||
|
ANNOTATION_BLACKLIST = unmodifiableSet(blacklist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This information has been lifted from:
|
* This information has been lifted from:
|
||||||
* @link <a href="https://github.com/JetBrains/kotlin/blob/master/core/runtime.jvm/src/kotlin/Metadata.kt">Metadata.kt</a>
|
*
|
||||||
|
* @link <a href="https://github.com/JetBrains/kotlin/blob/master/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt">KotlinClassHeader.Kind</a>
|
||||||
|
* @link <a href="https://github.com/JetBrains/kotlin/blob/master/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java">JvmAnnotationNames</a>
|
||||||
*/
|
*/
|
||||||
private static final String KOTLIN_METADATA = "kotlin.Metadata";
|
private static final String KOTLIN_METADATA = "kotlin.Metadata";
|
||||||
private static final String KOTLIN_CLASSTYPE_METHOD = "k";
|
private static final String KOTLIN_CLASSTYPE_METHOD = "k";
|
||||||
@ -174,8 +183,8 @@ public class ScanApi extends DefaultTask {
|
|||||||
File target = toTarget(source);
|
File target = toTarget(source);
|
||||||
getLogger().info("API file: {}", target.getAbsolutePath());
|
getLogger().info("API file: {}", target.getAbsolutePath());
|
||||||
try (
|
try (
|
||||||
URLClassLoader appLoader = new URLClassLoader(new URL[]{ toURL(source) }, classpathLoader);
|
URLClassLoader appLoader = new URLClassLoader(new URL[]{toURL(source)}, classpathLoader);
|
||||||
PrintWriter writer = new PrintWriter(target, "UTF-8")
|
ApiPrintWriter writer = new ApiPrintWriter(target, "UTF-8")
|
||||||
) {
|
) {
|
||||||
scan(writer, appLoader);
|
scan(writer, appLoader);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -183,7 +192,7 @@ public class ScanApi extends DefaultTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scan(PrintWriter writer, ClassLoader appLoader) {
|
void scan(ApiPrintWriter writer, ClassLoader appLoader) {
|
||||||
Set<String> inherited = new HashSet<>();
|
Set<String> inherited = new HashSet<>();
|
||||||
ScanResult result = new FastClasspathScanner(getScanSpecification())
|
ScanResult result = new FastClasspathScanner(getScanSpecification())
|
||||||
.matchAllAnnotationClasses(annotation -> {
|
.matchAllAnnotationClasses(annotation -> {
|
||||||
@ -235,21 +244,14 @@ public class ScanApi extends DefaultTask {
|
|||||||
invisibleAnnotations = unmodifiableSet(invisible);
|
invisibleAnnotations = unmodifiableSet(invisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeApis(PrintWriter writer, ScanResult result) {
|
private void writeApis(ApiPrintWriter writer, ScanResult result) {
|
||||||
Map<String, ClassInfo> allInfo = result.getClassNameToClassInfo();
|
Map<String, ClassInfo> allInfo = result.getClassNameToClassInfo();
|
||||||
result.getNamesOfAllClasses().forEach(className -> {
|
result.getNamesOfAllClasses().forEach(className -> {
|
||||||
if (className.contains(".internal.")) {
|
if (className.contains(".internal.")) {
|
||||||
// These classes belong to internal Corda packages.
|
// These classes belong to internal Corda packages.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (className.contains("$$inlined$")) {
|
|
||||||
/*
|
|
||||||
* These classes are internally generated by the Kotlin compiler
|
|
||||||
* and are not exposed as part of the public API
|
|
||||||
* TODO: Filter out using EnclosingMethod attribute in classfile
|
|
||||||
*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ClassInfo classInfo = allInfo.get(className);
|
ClassInfo classInfo = allInfo.get(className);
|
||||||
if (classInfo.getClassLoaders() == null) {
|
if (classInfo.getClassLoaders() == null) {
|
||||||
// Ignore classes that belong to one of our target ClassLoader's parents.
|
// Ignore classes that belong to one of our target ClassLoader's parents.
|
||||||
@ -268,81 +270,54 @@ public class ScanApi extends DefaultTask {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (classInfo.getFullyQualifiedContainingMethodName() != null) {
|
||||||
|
// Ignore Kotlin auto-generated internal classes
|
||||||
|
// which are not part of the api
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int kotlinClassType = getKotlinClassType(javaClass);
|
int kotlinClassType = getKotlinClassType(javaClass);
|
||||||
if (kotlinClassType == KOTLIN_SYNTHETIC) {
|
if (kotlinClassType == KOTLIN_SYNTHETIC) {
|
||||||
// Exclude classes synthesised by the Kotlin compiler.
|
// Exclude classes synthesised by the Kotlin compiler.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeClass(writer, classInfo, javaClass.getModifiers());
|
writeClass(writer, classInfo);
|
||||||
writeMethods(writer, classInfo.getMethodAndConstructorInfo());
|
writeMethods(writer, classInfo.getMethodAndConstructorInfo());
|
||||||
writeFields(writer, classInfo.getFieldInfo());
|
writeFields(writer, classInfo.getFieldInfo());
|
||||||
writer.println("##");
|
writer.println("##");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeClass(PrintWriter writer, ClassInfo classInfo, int modifiers) {
|
private void writeClass(ApiPrintWriter writer, ClassInfo classInfo) {
|
||||||
if (classInfo.isAnnotation()) {
|
if (classInfo.isAnnotation()) {
|
||||||
/*
|
writer.println(classInfo, INTERFACE_MASK, emptyList());
|
||||||
* Annotation declaration.
|
|
||||||
*/
|
|
||||||
writer.append(Modifier.toString(modifiers & INTERFACE_MASK));
|
|
||||||
writer.append(" @interface ").print(classInfo);
|
|
||||||
} else if (classInfo.isStandardClass()) {
|
} else if (classInfo.isStandardClass()) {
|
||||||
/*
|
writer.println(classInfo, CLASS_MASK, toNames(readClassAnnotationsFor(classInfo)).visible);
|
||||||
* Class declaration.
|
|
||||||
*/
|
|
||||||
Names annotationNames = toNames(readClassAnnotationsFor(classInfo));
|
|
||||||
if (!annotationNames.visible.isEmpty()) {
|
|
||||||
writer.append(asAnnotations(annotationNames.visible));
|
|
||||||
}
|
|
||||||
writer.append(Modifier.toString(modifiers & CLASS_MASK));
|
|
||||||
writer.append(" class ").print(classInfo);
|
|
||||||
Set<ClassInfo> superclasses = classInfo.getDirectSuperclasses();
|
|
||||||
if (!superclasses.isEmpty()) {
|
|
||||||
writer.append(" extends ").print(stringOf(superclasses));
|
|
||||||
}
|
|
||||||
Set<ClassInfo> interfaces = classInfo.getDirectlyImplementedInterfaces();
|
|
||||||
if (!interfaces.isEmpty()) {
|
|
||||||
writer.append(" implements ").print(stringOf(interfaces));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
writer.println(classInfo, INTERFACE_MASK, toNames(readInterfaceAnnotationsFor(classInfo)).visible);
|
||||||
* Interface declaration.
|
|
||||||
*/
|
|
||||||
Names annotationNames = toNames(readInterfaceAnnotationsFor(classInfo));
|
|
||||||
if (!annotationNames.visible.isEmpty()) {
|
|
||||||
writer.append(asAnnotations(annotationNames.visible));
|
|
||||||
}
|
|
||||||
writer.append(Modifier.toString(modifiers & INTERFACE_MASK));
|
|
||||||
writer.append(" interface ").print(classInfo);
|
|
||||||
Set<ClassInfo> superinterfaces = classInfo.getDirectSuperinterfaces();
|
|
||||||
if (!superinterfaces.isEmpty()) {
|
|
||||||
writer.append(" extends ").print(stringOf(superinterfaces));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
writer.println();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeMethods(PrintWriter writer, List<MethodInfo> methods) {
|
private void writeMethods(ApiPrintWriter writer, List<MethodInfo> methods) {
|
||||||
sort(methods);
|
sort(methods);
|
||||||
for (MethodInfo method : methods) {
|
for (MethodInfo method : methods) {
|
||||||
if (isVisible(method.getAccessFlags()) // Only public and protected methods
|
if (isVisible(method.getModifiers()) // Only public and protected methods
|
||||||
&& isValid(method.getAccessFlags(), METHOD_MASK) // Excludes bridge and synthetic methods
|
&& isValid(method.getModifiers(), METHOD_MASK) // Excludes bridge and synthetic methods
|
||||||
&& !hasInternalAnnotation(method.getAnnotationNames()) // Excludes methods annotated as @CordaInternal
|
&& !hasInternalAnnotation(method.getAnnotationNames()) // Excludes methods annotated as @CordaInternal
|
||||||
&& !isKotlinInternalScope(method)) {
|
&& !isKotlinInternalScope(method)) {
|
||||||
writer.append(" ").println(filterAnnotationsFor(method));
|
writer.println(filterAnnotationsFor(method), " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeFields(PrintWriter output, List<FieldInfo> fields) {
|
private void writeFields(ApiPrintWriter writer, List<FieldInfo> fields) {
|
||||||
sort(fields);
|
sort(fields);
|
||||||
for (FieldInfo field : fields) {
|
for (FieldInfo field : fields) {
|
||||||
if (isVisible(field.getAccessFlags())
|
if (isVisible(field.getModifiers())
|
||||||
&& isValid(field.getAccessFlags(), FIELD_MASK)
|
&& isValid(field.getModifiers(), FIELD_MASK)
|
||||||
&& !hasInternalAnnotation(field.getAnnotationNames())) {
|
&& !hasInternalAnnotation(field.getAnnotationNames())) {
|
||||||
output.append(" ").println(filterAnnotationsFor(field));
|
writer.println(filterAnnotationsFor(field), " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,10 +338,18 @@ public class ScanApi extends DefaultTask {
|
|||||||
|
|
||||||
private Names toNames(Collection<ClassInfo> classes) {
|
private Names toNames(Collection<ClassInfo> classes) {
|
||||||
Map<Boolean, List<String>> partitioned = classes.stream()
|
Map<Boolean, List<String>> partitioned = classes.stream()
|
||||||
.map(ClassInfo::toString)
|
.map(ClassInfo::getClassName)
|
||||||
.filter(ScanApi::isApplicationClass)
|
.filter(ScanApi::isApplicationClass)
|
||||||
.collect(partitioningBy(this::isVisibleAnnotation, toCollection(ArrayList::new)));
|
.collect(partitioningBy(this::isVisibleAnnotation, toCollection(ArrayList::new)));
|
||||||
return new Names(ordering(partitioned.get(true)), ordering(partitioned.get(false)));
|
List<String> visible = partitioned.get(true);
|
||||||
|
int idx = visible.indexOf(DONOTIMPLEMENT_ANNOTATION_NAME);
|
||||||
|
if (idx != -1) {
|
||||||
|
swap(visible, 0, idx);
|
||||||
|
sort(visible.subList(1, visible.size()));
|
||||||
|
} else {
|
||||||
|
sort(visible);
|
||||||
|
}
|
||||||
|
return new Names(visible, ordering(partitioned.get(false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<ClassInfo> readClassAnnotationsFor(ClassInfo classInfo) {
|
private Set<ClassInfo> readClassAnnotationsFor(ClassInfo classInfo) {
|
||||||
@ -396,12 +379,17 @@ public class ScanApi extends DefaultTask {
|
|||||||
return new MethodInfo(
|
return new MethodInfo(
|
||||||
method.getClassName(),
|
method.getClassName(),
|
||||||
method.getMethodName(),
|
method.getMethodName(),
|
||||||
method.getAccessFlags(),
|
method.getAnnotationInfo()
|
||||||
method.getTypeDescriptor(),
|
.stream()
|
||||||
method.getAnnotationNames().stream()
|
|
||||||
.filter(this::isVisibleAnnotation)
|
.filter(this::isVisibleAnnotation)
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(toList())
|
.collect(toList()),
|
||||||
|
method.getModifiers(),
|
||||||
|
method.getTypeDescriptorStr(),
|
||||||
|
method.getTypeSignatureStr(),
|
||||||
|
method.getParameterNames(),
|
||||||
|
method.getParameterModifiers(),
|
||||||
|
method.getParameterAnnotationInfo()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,18 +397,23 @@ public class ScanApi extends DefaultTask {
|
|||||||
return new FieldInfo(
|
return new FieldInfo(
|
||||||
field.getClassName(),
|
field.getClassName(),
|
||||||
field.getFieldName(),
|
field.getFieldName(),
|
||||||
field.getAccessFlags(),
|
field.getModifiers(),
|
||||||
field.getTypeDescriptor(),
|
field.getTypeDescriptorStr(),
|
||||||
|
field.getTypeSignatureStr(),
|
||||||
field.getConstFinalValue(),
|
field.getConstFinalValue(),
|
||||||
field.getAnnotationNames().stream()
|
field.getAnnotationInfo().stream()
|
||||||
.filter(this::isVisibleAnnotation)
|
.filter(this::isVisibleAnnotation)
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(toList())
|
.collect(toList())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVisibleAnnotation(String annotationName) {
|
private boolean isVisibleAnnotation(AnnotationInfo annotation) {
|
||||||
return !invisibleAnnotations.contains(annotationName);
|
return isVisibleAnnotation(annotation.getAnnotationName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isVisibleAnnotation(String className) {
|
||||||
|
return !invisibleAnnotations.contains(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasInternalAnnotation(Collection<String> annotationNames) {
|
private boolean hasInternalAnnotation(Collection<String> annotationNames) {
|
||||||
@ -445,14 +438,6 @@ public class ScanApi extends DefaultTask {
|
|||||||
return (accessFlags & VISIBILITY_MASK) != 0;
|
return (accessFlags & VISIBILITY_MASK) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String stringOf(Collection<ClassInfo> items) {
|
|
||||||
return items.stream().map(ClassInfo::toString).collect(joining(", "));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String asAnnotations(Collection<String> items) {
|
|
||||||
return items.stream().collect(joining(" @", "@", " "));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isApplicationClass(String typeName) {
|
private static boolean isApplicationClass(String typeName) {
|
||||||
return !typeName.startsWith("java.") && !typeName.startsWith("kotlin.");
|
return !typeName.startsWith("java.") && !typeName.startsWith("kotlin.");
|
||||||
}
|
}
|
||||||
@ -466,13 +451,14 @@ public class ScanApi extends DefaultTask {
|
|||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
urls.add(toURL(file));
|
urls.add(toURL(file));
|
||||||
}
|
}
|
||||||
return urls.toArray(new URL[urls.size()]);
|
return urls.toArray(new URL[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Names {
|
class Names {
|
||||||
List<String> visible;
|
List<String> visible;
|
||||||
@SuppressWarnings("WeakerAccess") List<String> hidden;
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
List<String> hidden;
|
||||||
|
|
||||||
Names(List<String> visible, List<String> hidden) {
|
Names(List<String> visible, List<String> hidden) {
|
||||||
this.visible = unmodifiable(visible);
|
this.visible = unmodifiable(visible);
|
||||||
|
@ -1,52 +1,37 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class AnnotatedClassTest {
|
public class AnnotatedClassTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "annotated-class");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("annotated-class/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnnotatedClass() throws IOException {
|
public void testAnnotatedClass() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getApiLines())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
.containsSequence(
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
"@AlsoInherited",
|
||||||
.withPluginClasspath()
|
"@IsInherited",
|
||||||
.build();
|
"@NotInherited",
|
||||||
String output = result.getOutput();
|
"public class net.corda.example.HasInheritedAnnotation extends java.lang.Object")
|
||||||
System.out.println(output);
|
.containsSequence(
|
||||||
|
"@AlsoInherited",
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
"@IsInherited",
|
||||||
assertNotNull(scanApi);
|
"public class net.corda.example.InheritingAnnotations extends net.corda.example.HasInheritedAnnotation")
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
.containsSequence(
|
||||||
|
"@DoNotImplement",
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "annotated-class.txt");
|
"@AnAnnotation",
|
||||||
assertThat(api).isRegularFile();
|
"public class net.corda.example.DoNotImplementAnnotation extends java.lang.Object");
|
||||||
assertThat(Files.readAllLines(api)).containsOnlyOnce(
|
|
||||||
"@net.corda.annotation.AlsoInherited @net.corda.annotation.IsInherited @net.corda.annotation.NotInherited public class net.corda.example.HasInheritedAnnotation extends java.lang.Object",
|
|
||||||
"@net.corda.annotation.AlsoInherited @net.corda.annotation.IsInherited public class net.corda.example.InheritingAnnotations extends net.corda.example.HasInheritedAnnotation"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,29 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class AnnotatedFieldTest {
|
public class AnnotatedFieldTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "annotated-field");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("annotated-field/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnnotatedField() throws IOException {
|
public void testAnnotatedField() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getApiLines())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
.containsSequence(
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
" @A",
|
||||||
.withPluginClasspath()
|
" @B",
|
||||||
.build();
|
" @C",
|
||||||
String output = result.getOutput();
|
" public static final String ANNOTATED_FIELD = \"<string-value>\"");
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "annotated-field.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertThat(Files.readAllLines(api)).containsOnlyOnce(
|
|
||||||
"public class net.corda.example.HasAnnotatedField extends java.lang.Object",
|
|
||||||
" @net.corda.example.A @net.corda.example.B @net.corda.example.C public static final String ANNOTATED_FIELD = \"<string-value>\""
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,38 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class AnnotatedInterfaceTest {
|
public class AnnotatedInterfaceTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "annotated-interface");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("annotated-interface/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnnotatedInterface() throws IOException {
|
public void testAnnotatedInterface() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getApiLines())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
.containsSequence(
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
"@AlsoInherited",
|
||||||
.withPluginClasspath()
|
"@IsInherited",
|
||||||
.build();
|
"@NotInherited",
|
||||||
String output = result.getOutput();
|
"public interface net.corda.example.HasInheritedAnnotation")
|
||||||
System.out.println(output);
|
.containsSequence(
|
||||||
|
"@AlsoInherited",
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
"@IsInherited",
|
||||||
assertNotNull(scanApi);
|
"public interface net.corda.example.InheritingAnnotations extends net.corda.example.HasInheritedAnnotation")
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
.containsSequence(
|
||||||
|
"@DoNotImplement",
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "annotated-interface.txt");
|
"@AnAnnotation",
|
||||||
assertThat(api).isRegularFile();
|
"public interface net.corda.example.DoNotImplementAnnotation"
|
||||||
assertThat(Files.readAllLines(api)).containsOnlyOnce(
|
);
|
||||||
"@net.corda.annotation.AlsoInherited @net.corda.annotation.IsInherited @net.corda.annotation.NotInherited public interface net.corda.example.HasInheritedAnnotation",
|
|
||||||
"@net.corda.annotation.AlsoInherited @net.corda.annotation.IsInherited public interface net.corda.example.InheritingAnnotations extends net.corda.example.HasInheritedAnnotation"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,35 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class AnnotatedMethodTest {
|
public class AnnotatedMethodTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "annotated-method");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("annotated-method/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnnotatedMethod() throws IOException {
|
public void testAnnotatedMethod() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getApiLines())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
.containsSequence(
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
" @A",
|
||||||
.withPluginClasspath()
|
" @B",
|
||||||
.build();
|
" @C",
|
||||||
String output = result.getOutput();
|
" public void hasAnnotation()")
|
||||||
System.out.println(output);
|
//Should not include @Deprecated annotation
|
||||||
|
.containsSequence(
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
"public class net.corda.example.HasDeprecatedMethod extends java.lang.Object",
|
||||||
assertNotNull(scanApi);
|
" public <init>()",
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
" public void isDeprecated()"
|
||||||
|
);
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "annotated-method.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertThat(Files.readAllLines(api)).containsOnlyOnce(
|
|
||||||
"public class net.corda.example.HasAnnotatedMethod extends java.lang.Object",
|
|
||||||
" @net.corda.example.A @net.corda.example.B @net.corda.example.C public void hasAnnotation()"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,50 +1,26 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class BasicAnnotationTest {
|
public class BasicAnnotationTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "basic-annotation");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("basic-annotation/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicAnnotation() throws IOException {
|
public void testBasicAnnotation() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "basic-annotation.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"public @interface net.corda.example.BasicAnnotation\n" +
|
"public @interface net.corda.example.BasicAnnotation\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,28 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class BasicClassTest {
|
public class BasicClassTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "basic-class");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("basic-class/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicClass() throws IOException {
|
public void testBasicClass() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "basic-class.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"public class net.corda.example.BasicClass extends java.lang.Object\n" +
|
"public class net.corda.example.BasicClass extends java.lang.Object\n" +
|
||||||
" public <init>(String)\n" +
|
" public <init>(String)\n" +
|
||||||
" public String getName()\n" +
|
" public String getName()\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,51 +1,27 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class BasicInterfaceTest {
|
public class BasicInterfaceTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "basic-interface");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("basic-interface/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicInterface() throws IOException {
|
public void testBasicInterface() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "basic-interface.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"public interface net.corda.example.BasicInterface\n" +
|
"public interface net.corda.example.BasicInterface\n" +
|
||||||
" public abstract java.math.BigInteger getBigNumber()\n" +
|
" public abstract java.math.BigInteger getBigNumber()\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,28 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class ClassWithInternalAnnotationTest {
|
public class ClassWithInternalAnnotationTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "class-internal-annotation");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("class-internal-annotation/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClassWithInternalAnnotation() throws IOException {
|
public void testClassWithInternalAnnotation() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getOutput()).contains("net.corda.example.InvisibleAnnotation");
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
assertThat(output).contains("net.corda.example.InvisibleAnnotation");
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "class-internal-annotation.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals("public class net.corda.example.AnnotatedClass extends java.lang.Object\n" +
|
assertEquals("public class net.corda.example.AnnotatedClass extends java.lang.Object\n" +
|
||||||
" public <init>()\n" +
|
" public <init>()\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,24 @@ package net.corda.plugins;
|
|||||||
|
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||||
import static java.nio.file.StandardCopyOption.*;
|
|
||||||
|
|
||||||
public final class CopyUtils {
|
public final class CopyUtils {
|
||||||
private static final String testGradleUserHome = System.getProperty("test.gradle.user.home", "");
|
|
||||||
|
|
||||||
private CopyUtils() {
|
private CopyUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long installResource(TemporaryFolder folder, String resourceName) throws IOException {
|
||||||
|
File buildFile = folder.newFile(resourceName.substring(1 + resourceName.lastIndexOf('/')));
|
||||||
|
return copyResourceTo(resourceName, buildFile);
|
||||||
|
}
|
||||||
|
|
||||||
public static long copyResourceTo(String resourceName, Path target) throws IOException {
|
public static long copyResourceTo(String resourceName, Path target) throws IOException {
|
||||||
try (InputStream input = CopyUtils.class.getClassLoader().getResourceAsStream(resourceName)) {
|
try (InputStream input = CopyUtils.class.getClassLoader().getResourceAsStream(resourceName)) {
|
||||||
return Files.copy(input, target, REPLACE_EXISTING);
|
return Files.copy(input, target, REPLACE_EXISTING);
|
||||||
@ -28,22 +29,4 @@ public final class CopyUtils {
|
|||||||
public static long copyResourceTo(String resourceName, File target) throws IOException {
|
public static long copyResourceTo(String resourceName, File target) throws IOException {
|
||||||
return copyResourceTo(resourceName, target.toPath());
|
return copyResourceTo(resourceName, target.toPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toString(Path file) throws IOException {
|
|
||||||
return new String(Files.readAllBytes(file), UTF_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Path pathOf(TemporaryFolder folder, String... elements) {
|
|
||||||
return Paths.get(folder.getRoot().getAbsolutePath(), elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getGradleArgsForTasks(String... taskNames) {
|
|
||||||
List<String> args = new ArrayList<>(taskNames.length + 3);
|
|
||||||
Collections.addAll(args, taskNames);
|
|
||||||
args.add("--info");
|
|
||||||
if (!testGradleUserHome.isEmpty()) {
|
|
||||||
Collections.addAll(args,"-g", testGradleUserHome);
|
|
||||||
}
|
|
||||||
return args;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,51 +1,36 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
import org.junit.ClassRule;
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class ExtendedClassTest {
|
public class ExtendedClassTest {
|
||||||
@Rule
|
private static final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private static final GradleProject testProject = new GradleProject(testProjectDir, "extended-class");
|
||||||
|
|
||||||
@Before
|
@ClassRule
|
||||||
public void setup() throws IOException {
|
public static final TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("extended-class/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtendedClass() throws IOException {
|
public void testExtendedClass() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getApiLines()).containsSequence(
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
"public class net.corda.example.ExtendedClass extends java.io.FilterInputStream",
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
" public <init>(java.io.InputStream)",
|
||||||
.withPluginClasspath()
|
"##");
|
||||||
.build();
|
}
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
@Test
|
||||||
assertNotNull(scanApi);
|
public void testImplementingClass() throws IOException {
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
assertThat(testProject.getApiLines()).containsSequence(
|
||||||
|
"public class net.corda.example.ImplementingClass extends java.lang.Object implements java.io.Closeable",
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "extended-class.txt");
|
" public <init>()",
|
||||||
assertThat(api).isRegularFile();
|
" public void close()",
|
||||||
assertEquals(
|
"##");
|
||||||
"public class net.corda.example.ExtendedClass extends java.io.FilterInputStream\n" +
|
|
||||||
" public <init>(java.io.InputStream)\n" +
|
|
||||||
"##\n", CopyUtils.toString(api));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,28 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class ExtendedInterfaceTest {
|
public class ExtendedInterfaceTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "extended-interface");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("extended-interface/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtendedInterface() throws IOException {
|
public void testExtendedInterface() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "extended-interface.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"public interface net.corda.example.ExtendedInterface extends java.util.concurrent.Future\n" +
|
"public interface net.corda.example.ExtendedInterface extends java.util.concurrent.Future\n" +
|
||||||
" public abstract String getName()\n" +
|
" public abstract String getName()\n" +
|
||||||
" public abstract void setName(String)\n" +
|
" public abstract void setName(String)\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,55 +1,31 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class FieldWithInternalAnnotationTest {
|
public class FieldWithInternalAnnotationTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "field-internal-annotation");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("field-internal-annotation/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFieldWithInternalAnnotations() throws IOException {
|
public void testFieldWithInternalAnnotations() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getOutput())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
assertThat(output)
|
|
||||||
.contains("net.corda.example.field.InvisibleAnnotation")
|
.contains("net.corda.example.field.InvisibleAnnotation")
|
||||||
.contains("net.corda.example.field.LocalInvisibleAnnotation");
|
.contains("net.corda.example.field.LocalInvisibleAnnotation");
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "field-internal-annotation.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals("public class net.corda.example.field.HasVisibleField extends java.lang.Object\n" +
|
assertEquals("public class net.corda.example.field.HasVisibleField extends java.lang.Object\n" +
|
||||||
" public <init>()\n" +
|
" public <init>()\n" +
|
||||||
" public String hasInvisibleAnnotations\n" +
|
" public String hasInvisibleAnnotations\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
package net.corda.plugins;
|
||||||
|
|
||||||
|
import org.gradle.testkit.runner.BuildResult;
|
||||||
|
import org.gradle.testkit.runner.BuildTask;
|
||||||
|
import org.gradle.testkit.runner.GradleRunner;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
import org.junit.runner.Description;
|
||||||
|
import org.junit.runners.model.Statement;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.util.Collections.emptyList;
|
||||||
|
import static java.util.stream.Collectors.joining;
|
||||||
|
import static net.corda.plugins.CopyUtils.*;
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
import static org.gradle.testkit.runner.TaskOutcome.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit rule to execute the scanApi Gradle task. This rule should be chained with TemporaryFolder.
|
||||||
|
*/
|
||||||
|
public class GradleProject implements TestRule {
|
||||||
|
private static final String testGradleUserHome = System.getProperty("test.gradle.user.home", "");
|
||||||
|
|
||||||
|
private final TemporaryFolder projectDir;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private String output;
|
||||||
|
private Path api;
|
||||||
|
|
||||||
|
public GradleProject(TemporaryFolder projectDir, String name) {
|
||||||
|
this.projectDir = projectDir;
|
||||||
|
this.name = name;
|
||||||
|
this.output = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path getApi() {
|
||||||
|
return api;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getApiLines() throws IOException {
|
||||||
|
// Files.readAllLines() uses UTF-8 by default.
|
||||||
|
return (api == null) ? emptyList() : Files.readAllLines(api);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApiText() throws IOException {
|
||||||
|
return getApiLines().stream().collect(joining("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Statement apply(Statement base, Description description) {
|
||||||
|
return new Statement() {
|
||||||
|
@Override
|
||||||
|
public void evaluate() throws Throwable {
|
||||||
|
installResource(projectDir, name + "/build.gradle");
|
||||||
|
installResource(projectDir, "gradle.properties");
|
||||||
|
|
||||||
|
BuildResult result = GradleRunner.create()
|
||||||
|
.withProjectDir(projectDir.getRoot())
|
||||||
|
.withArguments(getGradleArgsForTasks("scanApi"))
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build();
|
||||||
|
output = result.getOutput();
|
||||||
|
System.out.println(output);
|
||||||
|
|
||||||
|
BuildTask scanApi = result.task(":scanApi");
|
||||||
|
assertNotNull(scanApi);
|
||||||
|
assertEquals(SUCCESS, scanApi.getOutcome());
|
||||||
|
|
||||||
|
api = pathOf(projectDir, "build", "api", name + ".txt");
|
||||||
|
assertThat(api).isRegularFile();
|
||||||
|
base.evaluate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path pathOf(TemporaryFolder folder, String... elements) {
|
||||||
|
return Paths.get(folder.getRoot().getAbsolutePath(), elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getGradleArgsForTasks(String... taskNames) {
|
||||||
|
List<String> args = new ArrayList<>(taskNames.length + 3);
|
||||||
|
Collections.addAll(args, taskNames);
|
||||||
|
args.add("--info");
|
||||||
|
if (!testGradleUserHome.isEmpty()) {
|
||||||
|
Collections.addAll(args,"-g", testGradleUserHome);
|
||||||
|
}
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
}
|
@ -1,52 +1,28 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class InternalAnnotationTest {
|
public class InternalAnnotationTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "internal-annotation");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("internal-annotation/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInternalAnnotations() throws IOException {
|
public void testInternalAnnotations() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getOutput())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
assertThat(output)
|
|
||||||
.contains("net.corda.core.CordaInternal")
|
.contains("net.corda.core.CordaInternal")
|
||||||
.contains("net.corda.example.CordaInternal");
|
.contains("net.corda.example.CordaInternal");
|
||||||
|
assertEquals("", testProject.getApiText());
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "internal-annotation.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals("", CopyUtils.toString(api));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,51 +1,27 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class InternalFieldTest {
|
public class InternalFieldTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "internal-field");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("internal-field/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInternalField() throws IOException {
|
public void testInternalField() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "internal-field.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"public class net.corda.example.WithInternalField extends java.lang.Object\n" +
|
"public class net.corda.example.WithInternalField extends java.lang.Object\n" +
|
||||||
" public <init>()\n" +
|
" public <init>()\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,50 +1,27 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class InternalMethodTest {
|
public class InternalMethodTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "internal-method");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("internal-method/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInternalMethod() throws IOException {
|
public void testInternalMethod() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "internal-method.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"public class net.corda.example.WithInternalMethod extends java.lang.Object\n" +
|
"public class net.corda.example.WithInternalMethod extends java.lang.Object\n" +
|
||||||
" public <init>()\n" +
|
" public <init>()\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,53 +1,29 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class InternalPackageTest {
|
public class InternalPackageTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "internal-package");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("internal-package/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInternalPackageIsIgnored() throws IOException {
|
public void testInternalPackageIsIgnored() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getOutput()).contains("net.corda.internal.InvisibleClass");
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
assertThat(output).contains("net.corda.internal.InvisibleClass");
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "internal-package.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"public class net.corda.VisibleClass extends java.lang.Object\n" +
|
"public class net.corda.VisibleClass extends java.lang.Object\n" +
|
||||||
" public <init>()\n" +
|
" public <init>()\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,98 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
import org.junit.ClassRule;
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class KotlinAnnotationsTest {
|
public class KotlinAnnotationsTest {
|
||||||
@Rule
|
private static final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private static final GradleProject testProject = new GradleProject(testProjectDir, "kotlin-annotations");
|
||||||
|
|
||||||
@Before
|
@ClassRule
|
||||||
public void setup() throws IOException {
|
public static final TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("kotlin-annotations/build.gradle", buildFile);
|
private static final String[] expectedClassWithDeprecatedFunctions = {
|
||||||
|
"public final class net.corda.example.HasDeprecatedFunctions extends java.lang.Object",
|
||||||
|
" public <init>()",
|
||||||
|
" @NotNull",
|
||||||
|
" public final String doSomething()",
|
||||||
|
"##"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] expectedClassWithJvmField = {
|
||||||
|
"public final class net.corda.example.HasJvmField extends java.lang.Object",
|
||||||
|
" public <init>()",
|
||||||
|
" @NotNull",
|
||||||
|
" public final String stringValue = \"Hello World\"",
|
||||||
|
"##"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] expectedClassWithJvmStaticFunction = {
|
||||||
|
"public final class net.corda.example.HasJvmStaticFunction extends java.lang.Object",
|
||||||
|
" public <init>()",
|
||||||
|
" public static final void doThing(String)",
|
||||||
|
" public static final net.corda.example.HasJvmStaticFunction$Companion Companion",
|
||||||
|
"##"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] expectedClassWithJvmStaticFunctionCompanion = {
|
||||||
|
"public static final class net.corda.example.HasJvmStaticFunction$Companion extends java.lang.Object",
|
||||||
|
" public final void doThing(String)",
|
||||||
|
"##"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] expectedClassWithOverloadedConstructor = {
|
||||||
|
"public final class net.corda.example.HasOverloadedConstructor extends java.lang.Object",
|
||||||
|
" public <init>()",
|
||||||
|
" public <init>(String)",
|
||||||
|
" public <init>(String, String)",
|
||||||
|
" public <init>(String, String, int)",
|
||||||
|
" @NotNull",
|
||||||
|
" public final String getNotNullable()",
|
||||||
|
" @Nullable",
|
||||||
|
" public final String getNullable()",
|
||||||
|
" public final int getNumber()",
|
||||||
|
"##"
|
||||||
|
};
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeprecatedAnnotation() throws IOException {
|
||||||
|
assertThat(testProject.getApiLines())
|
||||||
|
.containsSequence(expectedClassWithDeprecatedFunctions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKotlinAnnotations() throws IOException {
|
public void testJvmFieldAnnotation() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getApiLines())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
.containsSequence(expectedClassWithJvmField);
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
}
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
@Test
|
||||||
assertNotNull(scanApi);
|
public void testJvmStaticAnnotation() throws IOException {
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
assertThat(testProject.getApiLines())
|
||||||
|
.containsSequence(expectedClassWithJvmStaticFunction)
|
||||||
|
.containsSequence(expectedClassWithJvmStaticFunctionCompanion);
|
||||||
|
}
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "kotlin-annotations.txt");
|
@Test
|
||||||
assertThat(api).isRegularFile();
|
public void testJvmOverloadedAnnotation() throws IOException {
|
||||||
assertEquals(
|
assertThat(testProject.getApiLines())
|
||||||
"public final class net.corda.example.HasJvmField extends java.lang.Object\n" +
|
.containsSequence(expectedClassWithOverloadedConstructor);
|
||||||
" public <init>()\n" +
|
}
|
||||||
" @org.jetbrains.annotations.NotNull public final String stringValue = \"Hello World\"\n" +
|
|
||||||
"##\n" +
|
@Test
|
||||||
"public final class net.corda.example.HasJvmStaticFunction extends java.lang.Object\n" +
|
public void testJvmDefaultAnnotation() throws IOException {
|
||||||
" public <init>()\n" +
|
assertThat(testProject.getApiLines())
|
||||||
" @kotlin.jvm.JvmStatic public static final void doThing(String)\n" +
|
.containsSequence(
|
||||||
" public static final net.corda.example.HasJvmStaticFunction$Companion Companion\n" +
|
"public interface net.corda.example.HasDefaultMethod",
|
||||||
"##\n" +
|
" public void doSomething(String)",
|
||||||
"public static final class net.corda.example.HasJvmStaticFunction$Companion extends java.lang.Object\n" +
|
"##"
|
||||||
" @kotlin.jvm.JvmStatic public final void doThing(String)\n" +
|
);
|
||||||
"##\n" +
|
|
||||||
"public final class net.corda.example.HasOverloadedConstructor extends java.lang.Object\n" +
|
|
||||||
" public <init>()\n" +
|
|
||||||
" public <init>(String)\n" +
|
|
||||||
" public <init>(String, String)\n" +
|
|
||||||
" public <init>(String, String, int)\n" +
|
|
||||||
" @org.jetbrains.annotations.NotNull public final String getNotNullable()\n" +
|
|
||||||
" @org.jetbrains.annotations.Nullable public final String getNullable()\n" +
|
|
||||||
" public final int getNumber()\n" +
|
|
||||||
"##\n", CopyUtils.toString(api));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package net.corda.plugins;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class KotlinAutoGeneratedClassTest {
|
||||||
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
|
private final GradleProject testProject = new GradleProject(testProjectDir, "kotlin-auto-generated-class");
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testKotlinAutoGeneratedClassMethod() throws IOException {
|
||||||
|
assertEquals("public final class net.corda.example.ContainsAutoGeneratedClass extends java.lang.Object\n" +
|
||||||
|
" public <init>()\n" +
|
||||||
|
" public final void methodContainingInlinedFunction()\n" +
|
||||||
|
"##", testProject.getApiText());
|
||||||
|
}
|
||||||
|
}
|
@ -1,53 +1,29 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class KotlinInternalAnnotationTest {
|
public class KotlinInternalAnnotationTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "kotlin-internal-annotation");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("kotlin-internal-annotation/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKotlinInternalAnnotation() throws IOException {
|
public void testKotlinInternalAnnotation() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getOutput()).contains("net.corda.example.kotlin.CordaInternal");
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
assertThat(output).contains("net.corda.example.kotlin.CordaInternal");
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "kotlin-internal-annotation.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"public final class net.corda.example.kotlin.AnnotatedClass extends java.lang.Object\n" +
|
"public final class net.corda.example.kotlin.AnnotatedClass extends java.lang.Object\n" +
|
||||||
" public <init>()\n" +
|
" public <init>()\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,53 +1,29 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class KotlinLambdasTest {
|
public class KotlinLambdasTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "kotlin-lambdas");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("kotlin-lambdas/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKotlinLambdas() throws IOException {
|
public void testKotlinLambdas() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getOutput()).contains("net.corda.example.LambdaExpressions$testing$$inlined$schedule$1");
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
assertThat(output).contains("net.corda.example.LambdaExpressions$testing$$inlined$schedule$1");
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "kotlin-lambdas.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals("public final class net.corda.example.LambdaExpressions extends java.lang.Object\n" +
|
assertEquals("public final class net.corda.example.LambdaExpressions extends java.lang.Object\n" +
|
||||||
" public <init>()\n" +
|
" public <init>()\n" +
|
||||||
" public final void testing(kotlin.Unit)\n" +
|
" public final void testing(kotlin.Unit)\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,48 +1,38 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class KotlinVarargMethodTest {
|
public class KotlinVarargMethodTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "kotlin-vararg-method");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("kotlin-vararg-method/build.gradle", buildFile);
|
private static final String[] expectedInterfaceWithVarargMethod = {
|
||||||
}
|
"public interface net.corda.example.KotlinVarargMethod",
|
||||||
|
" public abstract void action(int...)",
|
||||||
|
"##"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] expectedInterfaceWithArrayVarargMethod = {
|
||||||
|
"public interface net.corda.example.KotlinVarargArrayMethod",
|
||||||
|
" public abstract void action(String[]...)",
|
||||||
|
"##"
|
||||||
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKotlinVarargMethod() throws IOException {
|
public void testKotlinVarargMethod() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getApiLines())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
.containsSequence(expectedInterfaceWithVarargMethod)
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
.containsSequence(expectedInterfaceWithArrayVarargMethod);
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "kotlin-vararg-method.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals("public interface net.corda.example.KotlinVarargMethod\n" +
|
|
||||||
" public abstract void action(Object...)\n" +
|
|
||||||
"##\n", CopyUtils.toString(api));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,55 +1,32 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
|
||||||
import org.gradle.testkit.runner.BuildTask;
|
|
||||||
import org.gradle.testkit.runner.GradleRunner;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class MethodWithInternalAnnotationTest {
|
public class MethodWithInternalAnnotationTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "method-internal-annotation");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("method-internal-annotation/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMethodWithInternalAnnotations() throws IOException {
|
public void testMethodWithInternalAnnotations() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
assertThat(testProject.getOutput())
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
assertThat(output)
|
|
||||||
.contains("net.corda.example.method.InvisibleAnnotation")
|
.contains("net.corda.example.method.InvisibleAnnotation")
|
||||||
.contains("net.corda.example.method.LocalInvisibleAnnotation");
|
.contains("net.corda.example.method.LocalInvisibleAnnotation");
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "method-internal-annotation.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals("public class net.corda.example.method.HasVisibleMethod extends java.lang.Object\n" +
|
assertEquals("public class net.corda.example.method.HasVisibleMethod extends java.lang.Object\n" +
|
||||||
" public <init>()\n" +
|
" public <init>()\n" +
|
||||||
" public void hasInvisibleAnnotations()\n" +
|
" public void hasInvisibleAnnotations()\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,48 +1,26 @@
|
|||||||
package net.corda.plugins;
|
package net.corda.plugins;
|
||||||
|
|
||||||
import org.gradle.testkit.runner.*;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.RuleChain;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
import org.junit.rules.TestRule;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static net.corda.plugins.CopyUtils.*;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class VarargMethodTest {
|
public class VarargMethodTest {
|
||||||
@Rule
|
private final TemporaryFolder testProjectDir = new TemporaryFolder();
|
||||||
public final TemporaryFolder testProjectDir = new TemporaryFolder();
|
private final GradleProject testProject = new GradleProject(testProjectDir, "vararg-method");
|
||||||
|
|
||||||
@Before
|
@Rule
|
||||||
public void setup() throws IOException {
|
public TestRule rules = RuleChain.outerRule(testProjectDir).around(testProject);
|
||||||
File buildFile = testProjectDir.newFile("build.gradle");
|
|
||||||
copyResourceTo("vararg-method/build.gradle", buildFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVarargMethod() throws IOException {
|
public void testVarargMethod() throws IOException {
|
||||||
BuildResult result = GradleRunner.create()
|
|
||||||
.withProjectDir(testProjectDir.getRoot())
|
|
||||||
.withArguments(getGradleArgsForTasks("scanApi"))
|
|
||||||
.withPluginClasspath()
|
|
||||||
.build();
|
|
||||||
String output = result.getOutput();
|
|
||||||
System.out.println(output);
|
|
||||||
|
|
||||||
BuildTask scanApi = result.task(":scanApi");
|
|
||||||
assertNotNull(scanApi);
|
|
||||||
assertEquals(SUCCESS, scanApi.getOutcome());
|
|
||||||
|
|
||||||
Path api = pathOf(testProjectDir, "build", "api", "vararg-method.txt");
|
|
||||||
assertThat(api).isRegularFile();
|
|
||||||
assertEquals("public interface net.corda.example.VarargMethod\n" +
|
assertEquals("public interface net.corda.example.VarargMethod\n" +
|
||||||
" public abstract void action(Object...)\n" +
|
" public abstract void action(Object...)\n" +
|
||||||
"##\n", CopyUtils.toString(api));
|
"##", testProject.getApiText());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package net.corda.example;
|
||||||
|
|
||||||
|
import net.corda.annotation.*;
|
||||||
|
import net.corda.core.*;
|
||||||
|
|
||||||
|
@AnAnnotation
|
||||||
|
@DoNotImplement
|
||||||
|
public class DoNotImplementAnnotation {
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package net.corda.example;
|
package net.corda.example;
|
||||||
|
|
||||||
import net.corda.annotation.*;
|
import net.corda.annotation.*;
|
||||||
|
import net.corda.core.*;
|
||||||
|
|
||||||
@NotInherited
|
@NotInherited
|
||||||
@IsInherited
|
@IsInherited
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.corda.example;
|
package net.corda.example;
|
||||||
|
|
||||||
public class InheritingAnnotations extends HasInheritedAnnotation {
|
public class InheritingAnnotations extends HasInheritedAnnotation {
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package net.corda.example;
|
||||||
|
|
||||||
|
import net.corda.annotation.*;
|
||||||
|
import net.corda.core.*;
|
||||||
|
|
||||||
|
@AnAnnotation
|
||||||
|
@DoNotImplement
|
||||||
|
public interface DoNotImplementAnnotation {
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package net.corda.example;
|
package net.corda.example;
|
||||||
|
|
||||||
import net.corda.annotation.*;
|
import net.corda.annotation.*;
|
||||||
|
import net.corda.core.*;
|
||||||
|
|
||||||
@NotInherited
|
@NotInherited
|
||||||
@IsInherited
|
@IsInherited
|
||||||
|
@ -5,4 +5,4 @@ public class HasAnnotatedMethod {
|
|||||||
public void hasAnnotation() {
|
public void hasAnnotation() {
|
||||||
System.out.println("VISIBLE ANNOTATIONS");
|
System.out.println("VISIBLE ANNOTATIONS");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package net.corda.example;
|
||||||
|
|
||||||
|
public class HasDeprecatedMethod {
|
||||||
|
@Deprecated
|
||||||
|
public void isDeprecated() { System.out.println("IS DEPRECATED");}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package net.corda.example;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class ImplementingClass implements Closeable {
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
org.gradle.jvmargs=-javaagent:"$jacocoAgent"=destfile="$buildDir/jacoco/test.exec",includes=net/corda/plugins/**
|
@ -23,6 +23,13 @@ dependencies {
|
|||||||
compile 'org.jetbrains.kotlin:kotlin-reflect:$kotlin_version'
|
compile 'org.jetbrains.kotlin:kotlin-reflect:$kotlin_version'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
freeCompilerArgs = ['-Xenable-jvm-default']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
baseName = "kotlin-annotations"
|
baseName = "kotlin-annotations"
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
@file:Suppress("UNUSED")
|
||||||
|
package net.corda.example
|
||||||
|
|
||||||
|
interface HasDefaultMethod {
|
||||||
|
// This annotation is an experimental feature of Kotlin 1.2.40
|
||||||
|
// and IntelliJ is probably complaining about it. But it will
|
||||||
|
// still build successfully in Gradle.
|
||||||
|
@JvmDefault
|
||||||
|
fun doSomething(message: String) {
|
||||||
|
println(message)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
@file:Suppress("UNUSED")
|
||||||
|
package net.corda.example
|
||||||
|
|
||||||
|
class HasDeprecatedFunctions @Deprecated("Dont use this anymore!") constructor () {
|
||||||
|
@Deprecated("Dont use this anymore!")
|
||||||
|
fun doSomething() = "123"
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
@file:Suppress("UNUSED")
|
||||||
package net.corda.example
|
package net.corda.example
|
||||||
|
|
||||||
class HasJvmField {
|
class HasJvmField {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
@file:Suppress("UNUSED")
|
||||||
package net.corda.example
|
package net.corda.example
|
||||||
|
|
||||||
class HasJvmStaticFunction {
|
class HasJvmStaticFunction {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
@file:Suppress("UNUSED")
|
||||||
package net.corda.example
|
package net.corda.example
|
||||||
|
|
||||||
class HasOverloadedConstructor @JvmOverloads constructor (
|
class HasOverloadedConstructor @JvmOverloads constructor (
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
plugins {
|
||||||
|
id 'net.corda.plugins.api-scanner'
|
||||||
|
id 'org.jetbrains.kotlin.jvm' version '$kotlin_version'
|
||||||
|
}
|
||||||
|
|
||||||
|
description 'Test appearance of Kotlin lambdas'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
kotlin {
|
||||||
|
srcDir file("../resources/test/kotlin-auto-generated-class/kotlin")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version'
|
||||||
|
compile 'org.jetbrains.kotlin:kotlin-reflect:$kotlin_version'
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName = "kotlin-auto-generated-class"
|
||||||
|
}
|
||||||
|
|
||||||
|
scanApi {
|
||||||
|
verbose = true
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package net.corda.example
|
||||||
|
|
||||||
|
class ContainsAutoGeneratedClass {
|
||||||
|
private open class PrivateInnerClass
|
||||||
|
|
||||||
|
private inline fun runSomething(crossinline action: PrivateInnerClass.() -> Unit): PrivateInnerClass {
|
||||||
|
return object: PrivateInnerClass() {
|
||||||
|
fun run() = action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val timer = PrivateInnerClass()
|
||||||
|
|
||||||
|
fun methodContainingInlinedFunction() {
|
||||||
|
runSomething {
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,9 @@
|
|||||||
package net.corda.example
|
package net.corda.example
|
||||||
|
|
||||||
interface KotlinVarargMethod {
|
interface KotlinVarargMethod {
|
||||||
fun action(vararg arg: Any?)
|
fun action(vararg arg: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KotlinVarargArrayMethod {
|
||||||
|
fun action(vararg arg: Array<String>)
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ open class Baseform : DefaultTask() {
|
|||||||
val plugin = project.convention.getPlugin(JavaPluginConvention::class.java)
|
val plugin = project.convention.getPlugin(JavaPluginConvention::class.java)
|
||||||
val classpath = plugin.sourceSets.getByName(MAIN_SOURCE_SET_NAME).runtimeClasspath
|
val classpath = plugin.sourceSets.getByName(MAIN_SOURCE_SET_NAME).runtimeClasspath
|
||||||
val urls = classpath.files.map { it.toURI().toURL() }.toTypedArray()
|
val urls = classpath.files.map { it.toURI().toURL() }.toTypedArray()
|
||||||
return URLClassLoader(urls, javaClass.classLoader).loadClass("net.corda.nodeapi.internal.network.NetworkBootstrapper")
|
return URLClassLoader(urls).loadClass("net.corda.nodeapi.internal.network.NetworkBootstrapper")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user