Prepare for reproducible builds

This commit is contained in:
Julian Raufelder 2021-01-15 20:39:46 +01:00
parent 357fb85ae0
commit c81b9463a6
No known key found for this signature in database
GPG Key ID: 17EE71F6634E381D
16 changed files with 144 additions and 141 deletions

View File

@ -34,6 +34,7 @@ public class IntentProcessor extends BaseProcessor {
intentsModelBuilder.add(generateIntentReader((TypeElement) element));
}
if (!intentAnnotatedElements.isEmpty()) {
intentAnnotatedElements.sort((e1, e2) -> e1.getSimpleName().toString().compareTo(e2.getSimpleName().toString()));
generateIntents(intentsModelBuilder.build(), intentAnnotatedElements);
}
}

View File

@ -1,21 +1,21 @@
package org.cryptomator.generator.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
public class ActivitiesModel {
private final List<ActivityModel> activities;
private final Set<ActivityModel> activities;
public static ActivitiesModel.Builder builder() {
return new Builder();
}
private ActivitiesModel(List<ActivityModel> activities) {
private ActivitiesModel(Set<ActivityModel> activities) {
this.activities = activities;
}
public List<ActivityModel> getActivities() {
public Set<ActivityModel> getActivities() {
return activities;
}
@ -29,7 +29,7 @@ public class ActivitiesModel {
public static class Builder {
private final List<ActivityModel> activities = new ArrayList<>();
private final Set<ActivityModel> activities = new TreeSet<>();
private Builder() {
}

View File

@ -12,7 +12,7 @@ import javax.lang.model.element.TypeElement;
import static java.util.stream.Collectors.toList;
public class ActivityModel {
public class ActivityModel implements Comparable<ActivityModel> {
private final String qualifiedName;
@ -128,4 +128,9 @@ public class ActivityModel {
public String getPresenterIntentFieldName() {
return presenterIntentFieldName;
}
@Override
public int compareTo(ActivityModel activityModel) {
return this.qualifiedName.compareTo(activityModel.qualifiedName);
}
}

View File

@ -6,7 +6,7 @@ import org.cryptomator.generator.utils.Type;
import java.util.Optional;
public class FragmentModel {
public class FragmentModel implements Comparable<FragmentModel> {
private final String qualifiedName;
@ -45,4 +45,9 @@ public class FragmentModel {
public boolean isHasPresenter() {
return hasPresenter;
}
@Override
public int compareTo(FragmentModel fragmentModel) {
return this.qualifiedName.compareTo(fragmentModel.qualifiedName);
}
}

View File

@ -1,21 +1,21 @@
package org.cryptomator.generator.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
public class FragmentsModel {
private final List<FragmentModel> fragments;
private final Set<FragmentModel> fragments;
public static FragmentsModel.Builder builder() {
return new Builder();
}
private FragmentsModel(List<FragmentModel> fragments) {
private FragmentsModel(Set<FragmentModel> fragments) {
this.fragments = fragments;
}
public List<FragmentModel> getFragments() {
public Set<FragmentModel> getFragments() {
return fragments;
}
@ -29,7 +29,7 @@ public class FragmentsModel {
public static class Builder {
private final List<FragmentModel> fragments = new ArrayList<>();
private final Set<FragmentModel> fragments = new TreeSet<>();
private Builder() {
}

View File

@ -4,18 +4,18 @@ import org.cryptomator.generator.ProcessorException;
import org.cryptomator.generator.utils.Field;
import org.cryptomator.generator.utils.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.lang.model.element.Element;
public class InstanceStateModel {
private final String javaPackage;
private final Map<Type, InstanceStateType> types = new HashMap<>();
private final Map<Type, InstanceStateType> types = new TreeMap<>();
public InstanceStateModel(String javaPackage) {
this.javaPackage = javaPackage;
@ -47,7 +47,7 @@ public class InstanceStateModel {
public static class InstanceStateType {
private final List<InstanceStateField> fields = new ArrayList<>();
private final SortedSet<InstanceStateField> fields = new TreeSet<>();
private final String qualifiedName;
public InstanceStateType(Type type) {
@ -62,12 +62,12 @@ public class InstanceStateModel {
return qualifiedName;
}
public List<InstanceStateField> getFields() {
public SortedSet<InstanceStateField> getFields() {
return fields;
}
}
public static class InstanceStateField {
public static class InstanceStateField implements Comparable<InstanceStateField> {
private static int nextBundleKey = 0;
@ -142,6 +142,10 @@ public class InstanceStateModel {
return field.element();
}
@Override
public int compareTo(InstanceStateField instanceStateField) {
return this.bundleKey.compareTo(instanceStateField.bundleKey);
}
}
}

View File

@ -2,13 +2,13 @@ package org.cryptomator.generator.model;
import org.cryptomator.generator.utils.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Stream;
public class InstanceStatesModel {
private final Map<String, InstanceStateModel> instanceStatesByPackage = new HashMap<>();
private final Map<String, InstanceStateModel> instanceStatesByPackage = new TreeMap<>();
public void add(Field field) {
String packageName = field.declaringType().packageName();

View File

@ -3,9 +3,12 @@ package org.cryptomator.generator.model;
import org.cryptomator.generator.Intent;
import org.cryptomator.generator.Optional;
import java.util.List;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
@ -14,16 +17,15 @@ import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import static java.lang.Character.toLowerCase;
import static java.util.stream.Collectors.toList;
public class IntentBuilderModel {
public class IntentBuilderModel implements Comparable<IntentBuilderModel> {
private final String javaPackage;
private final String className;
private final String targetActivity;
private final String targetActivitySimpleName;
private final String buildMethodName;
private final List<ParameterModel> parameters;
private final Set<ParameterModel> parameters;
public IntentBuilderModel(TypeElement type) {
this.javaPackage = javaPackage(type);
@ -47,9 +49,21 @@ public class IntentBuilderModel {
}
private static String targetActivity(TypeElement type) {
return type.getAnnotationMirrors().stream().filter(is(Intent.class)).findFirst().get().getElementValues().entrySet().stream().map(entry -> (Map.Entry<ExecutableElement, AnnotationValue>) entry)
.filter(entry -> "value".equals(entry.getKey().getSimpleName().toString())).map(Map.Entry::getValue).map(AnnotationValue::getValue).map(DeclaredType.class::cast).map(DeclaredType::asElement)
.map(TypeElement.class::cast).findFirst().get().getQualifiedName().toString();
return type //
.getAnnotationMirrors() //
.stream() //
.filter(is(Intent.class)) //
.findFirst().get().getElementValues().entrySet() //
.stream() //
.map(entry -> (Map.Entry<ExecutableElement, AnnotationValue>) entry) //
.filter(entry -> "value".equals(entry.getKey().getSimpleName().toString())) //
.map(Map.Entry::getValue) //
.map(AnnotationValue::getValue) //
.map(DeclaredType.class::cast) //
.map(DeclaredType::asElement) //
.map(TypeElement.class::cast) //
.findFirst().get() //
.getQualifiedName().toString();
}
private static Predicate<AnnotationMirror> is(Class<?> type) {
@ -66,8 +80,14 @@ public class IntentBuilderModel {
return toLowerCase(name.charAt(0)) + name.substring(1);
}
private static List<ParameterModel> parameters(TypeElement type) {
return type.getEnclosedElements().stream().filter(ExecutableElement.class::isInstance).map(ExecutableElement.class::cast).map(ParameterModel::new).collect(toList());
private static Set<ParameterModel> parameters(TypeElement type) {
return type //
.getEnclosedElements() //
.stream() //
.filter(ExecutableElement.class::isInstance) //
.map(ExecutableElement.class::cast) //
.map(ParameterModel::new) //
.collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ParameterModel::getName))));
}
private static String buildMethodName(TypeElement type) {
@ -101,6 +121,11 @@ public class IntentBuilderModel {
return buildMethodName;
}
@Override
public int compareTo(IntentBuilderModel intentBuilderModel) {
return (this.javaPackage + this.className).compareTo(intentBuilderModel.javaPackage + intentBuilderModel.className);
}
public static class ParameterModel {
private final String nameWithFirstCharUppercase;

View File

@ -3,9 +3,12 @@ package org.cryptomator.generator.model;
import org.cryptomator.generator.Intent;
import org.cryptomator.generator.Optional;
import java.util.List;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
@ -13,16 +16,14 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import static java.util.stream.Collectors.toList;
public class IntentReaderModel {
public class IntentReaderModel implements Comparable<IntentReaderModel> {
private final String javaPackage;
private final String className;
private final String targetActivity;
private final String intentInterface;
private final String readMethodName;
private final List<ParameterModel> parameters;
private final Set<ParameterModel> parameters;
public IntentReaderModel(TypeElement type) {
this.intentInterface = type.getQualifiedName().toString();
@ -46,9 +47,22 @@ public class IntentReaderModel {
}
private static String targetActivity(TypeElement type) {
return type.getAnnotationMirrors().stream().filter(is(Intent.class)).findFirst().get().getElementValues().entrySet().stream().map(entry -> (Map.Entry<ExecutableElement, AnnotationValue>) entry)
.filter(entry -> "value".equals(entry.getKey().getSimpleName().toString())).map(Map.Entry::getValue).map(AnnotationValue::getValue).map(DeclaredType.class::cast).map(DeclaredType::asElement)
.map(TypeElement.class::cast).findFirst().get().getQualifiedName().toString();
return type //
.getAnnotationMirrors() //
.stream() //
.filter(is(Intent.class)) //
.findFirst().get().getElementValues().entrySet() //
.stream() //
.map(entry -> (Map.Entry<ExecutableElement, AnnotationValue>) entry) //
.filter(entry -> "value".equals(entry.getKey().getSimpleName().toString())) //
.map(Map.Entry::getValue) //
.map(AnnotationValue::getValue) //
.map(DeclaredType.class::cast) //
.map(DeclaredType::asElement) //
.map(TypeElement.class::cast) //
.findFirst().get() //
.getQualifiedName() //
.toString();
}
private static Predicate<AnnotationMirror> is(Class<?> type) {
@ -59,8 +73,14 @@ public class IntentReaderModel {
};
}
private static List<ParameterModel> parameters(TypeElement type) {
return type.getEnclosedElements().stream().filter(ExecutableElement.class::isInstance).map(ExecutableElement.class::cast).map(ParameterModel::new).collect(toList());
private static Set<ParameterModel> parameters(TypeElement type) {
return type //
.getEnclosedElements() //
.stream() //
.filter(ExecutableElement.class::isInstance) //
.map(ExecutableElement.class::cast) //
.map(ParameterModel::new) //
.collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ParameterModel::getName))));
}
private static String readMethodName(TypeElement type) {
@ -94,6 +114,11 @@ public class IntentReaderModel {
return readMethodName;
}
@Override
public int compareTo(IntentReaderModel intentReaderModel) {
return (this.javaPackage + this.className).compareTo(intentReaderModel.javaPackage + intentReaderModel.className);
}
public static class ParameterModel {
private final String name;

View File

@ -1,27 +1,27 @@
package org.cryptomator.generator.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
public class IntentsModel {
private final List<IntentBuilderModel> builders;
private final List<IntentReaderModel> readers;
private final Set<IntentBuilderModel> builders;
private final Set<IntentReaderModel> readers;
public static IntentsModel.Builder builder() {
return new Builder();
}
private IntentsModel(List<IntentBuilderModel> builders, List<IntentReaderModel> readers) {
private IntentsModel(Set<IntentBuilderModel> builders, Set<IntentReaderModel> readers) {
this.builders = builders;
this.readers = readers;
}
public List<IntentBuilderModel> getBuilders() {
public Set<IntentBuilderModel> getBuilders() {
return builders;
}
public List<IntentReaderModel> getReaders() {
public Set<IntentReaderModel> getReaders() {
return readers;
}
@ -35,8 +35,8 @@ public class IntentsModel {
public static class Builder {
private final List<IntentBuilderModel> builders = new ArrayList<>();
private final List<IntentReaderModel> readers = new ArrayList<>();
private final Set<IntentBuilderModel> builders = new TreeSet<>();
private final Set<IntentReaderModel> readers = new TreeSet<>();
private Builder() {
}

View File

@ -9,7 +9,7 @@ import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeKind;
public class Method {
public class Method implements Comparable<Method> {
private final Utils utils;
private final ExecutableElement delegate;
@ -75,4 +75,9 @@ public class Method {
public Type declaringType() {
return new Type(utils, (TypeElement) delegate.getEnclosingElement());
}
@Override
public int compareTo(Method method) {
return this.delegate.getSimpleName().toString().compareTo(method.delegate.getSimpleName().toString());
}
}

View File

@ -14,7 +14,7 @@ import static javax.lang.model.element.ElementKind.FIELD;
import static javax.lang.model.type.TypeKind.ARRAY;
import static javax.lang.model.type.TypeKind.NONE;
public class Type {
public class Type implements Comparable<Type> {
private final TypeMirror mirror;
private final Optional<TypeElement> element;
@ -89,6 +89,7 @@ public class Type {
return element //
.map(type -> type.getEnclosedElements().stream() //
.filter(ExecutableElement.class::isInstance) //
.sorted((e1, e2) -> e1.getSimpleName().toString().compareTo(e2.getSimpleName().toString())) //
.map(ExecutableElement.class::cast) //
.filter(Method::isConstructor) //
.map(executableElement -> new Method(utils, executableElement)))
@ -99,20 +100,22 @@ public class Type {
return element //
.map(type -> type.getEnclosedElements().stream() //
.filter(ExecutableElement.class::isInstance) //
.sorted((e1, e2) -> e1.getSimpleName().toString().compareTo(e2.getSimpleName().toString())) //
.map(ExecutableElement.class::cast) //
.filter(Method::isRegularMethod) //
.map(executableElement -> new Method(utils, executableElement)))
.orElse(Stream.empty()); //
.orElse(Stream.empty());
}
public Stream<Field> fields() {
return element //
.map(type -> type.getEnclosedElements().stream() //
.filter(VariableElement.class::isInstance) //
.sorted((e1, e2) -> e1.getSimpleName().toString().compareTo(e2.getSimpleName().toString())) //
.map(VariableElement.class::cast) //
.filter(variable -> variable.getKind() == FIELD) //
.map(variableElement -> new Field(utils, variableElement)))
.orElse(Stream.empty()); //
.map(variableElement -> new Field(utils, variableElement))) //
.orElse(Stream.empty());
}
@Override
@ -133,6 +136,11 @@ public class Type {
return mirror.hashCode();
}
@Override
public int compareTo(Type type) {
return this.qualifiedName().compareTo(type.qualifiedName());
}
public Optional<Type> enclosingType() {
if (mirror instanceof DeclaredType) {
return Optional.ofNullable(((DeclaredType) mirror).getEnclosingType()) //

@ -1 +1 @@
Subproject commit eca34e843a1ca2d7953f0d7c22efe72572ce7dc1
Subproject commit fe4e04589043cb18011cae80aec7eab09b46ed44

View File

@ -47,12 +47,18 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
crunchPngs false
minifyEnabled false
shrinkResources false
useProguard false
}
debug {
signingConfig signingConfigs.debug
crunchPngs false
minifyEnabled false
shrinkResources false
testCoverageEnabled false
}
}

View File

@ -1,81 +0,0 @@
-useuniqueclassmembernames
# greenDAO 3, http://greenrobot.org/greendao/documentation/technical-faq
-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
public static java.lang.String TABLENAME;
}
-keep class **$Properties {*;}
-dontwarn org.greenrobot.greendao.database.**
-dontwarn net.sqlcipher.database.**
-dontwarn rx.**
# RxJava, https://github.com/artem-zinnatullin/RxJavaProGuardRules/blob/master/rxjava-proguard-rules/proguard-rules.txt
-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}
# Google API Client, https://github.com/google/google-api-java-client/blob/dev/google-api-client-assembly/proguard-google-api-client.txt
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
-dontwarn com.google.api.client.extensions.android.**
-dontwarn com.google.api.client.googleapis.extensions.android.**
-dontwarn com.google.api.client.googleapis.testing.TestUtils
-dontwarn com.google.android.gms.**
# okhttp3
-dontwarn okhttp3.**
-dontwarn okio.**
# Others
-dontwarn org.slf4j.**
-dontwarn com.dropbox.core.**
-dontwarn com.fernandocejas.frodo.core.**
-dontwarn com.google.errorprone.annotations.**
-dontwarn com.google.common.util.concurrent.FuturesGetChecked**
-keepclassmembers class com.microsoft.graph.http.GraphServiceException {
int mResponseCode;
}
-keep class com.nulabinc.zxcvbn.**
# https://stackoverflow.com/a/47555897/1759462
-dontwarn afu.org.checkerframework.**
-dontwarn org.checkerframework.**
# https://github.com/microsoftgraph/msgraph-sdk-java/issues/258#issue-452030712
-keep class com.microsoft.** { *; }
-keep class com.microsoft.**
-keep interface com.microsoft.** { *; }
-keepclasseswithmembernames class com.microsoft.** { *; }
-keep class com.sun.** { *; }
-keep class com.sun.**
-keep interface com.sun.** { *; }
# https://github.com/jwtk/jjwt
-keepattributes InnerClasses
-keep class io.jsonwebtoken.** { *; }
-keepnames class io.jsonwebtoken.* { *; }
-keepnames interface io.jsonwebtoken.* { *; }
-keep class org.bouncycastle.** { *; }
-keepnames class org.bouncycastle.** { *; }
-dontwarn org.bouncycastle.**
-keep class android.net.http.** { *; }
-keep interface org.apache.** { *; }
-keep enum org.apache.** { *; }
-keep class org.apache.** { *; }
-keep class org.apache.commons.** { *; }
-keep class org.apache.http.** { *; }
-keep class org.apache.harmony.** {*;}

@ -1 +1 @@
Subproject commit 951e3924349ec1607ed06663d32ec918abf09076
Subproject commit c3c247b63cb72a4f7f9ddc3272820e1ce636e56d