Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmc24 committed Jan 31, 2023
1 parent e69bbe7 commit 1947802
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ All enhancements should be accompanied by test coverage.
Our tests are based on [Spock](https://github.com/spockframework/spock).
Generally, it's best to extend our `FunctionalSpec` class, which provides useful functions for running the plugin within Gradle.

Note that the "build" task only tests the plugin against the a single version of Gradle/Avro.
Note that the "build" task only tests the plugin against a single version of Gradle/Avro.
If you want to test compatibility with a larger range, consider using the `testRecentVersionCompatibility` task or `testVersionCompatibility` task.

For information on how to use GitHub to submit a pull request, see [Collaborating on projects using issues and pull requests](https://help.github.com/categories/collaborating-on-projects-using-issues-and-pull-requests/).
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.util.*;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.inject.Inject;
import org.apache.avro.Conversion;
Expand All @@ -42,8 +46,11 @@
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.specs.NotSpec;
import org.gradle.api.tasks.*;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;

/**
* Task to generate Java source files based on Avro protocol files and Avro schema files using {@link Protocol} and
Expand All @@ -52,7 +59,6 @@
@SuppressWarnings("WeakerAccess")
@CacheableTask
public class GenerateAvroJavaTask extends OutputDirTask {
private FileCollection classpath;
private static Set<String> SUPPORTED_EXTENSIONS =
new SetBuilder<String>().add(Constants.PROTOCOL_EXTENSION).add(Constants.SCHEMA_EXTENSION).build();

Expand All @@ -66,6 +72,7 @@ public class GenerateAvroJavaTask extends OutputDirTask {
private final Property<Boolean> optionalGettersForNullableFieldsOnly;
private final Property<Boolean> createSetters;
private final Property<Boolean> enableDecimalLogicalType;
private FileCollection classpath;
private final MapProperty<String, Class<? extends LogicalTypes.LogicalTypeFactory>> logicalTypeFactories;
private final ListProperty<Class<? extends Conversion<?>>> customConversions;

Expand All @@ -78,7 +85,6 @@ public class GenerateAvroJavaTask extends OutputDirTask {
@Inject
public GenerateAvroJavaTask(ObjectFactory objects) {
super();
this.classpath = GradleCompatibility.createConfigurableFileCollection(getProject());
this.outputCharacterEncoding = objects.property(String.class);
this.stringType = objects.property(String.class).convention(Constants.DEFAULT_STRING_TYPE);
this.fieldVisibility = objects.property(String.class).convention(Constants.DEFAULT_FIELD_VISIBILITY);
Expand All @@ -91,14 +97,15 @@ public GenerateAvroJavaTask(ObjectFactory objects) {
.convention(Constants.DEFAULT_OPTIONAL_GETTERS_FOR_NULLABLE_FIELDS_ONLY);
this.createSetters = objects.property(Boolean.class).convention(Constants.DEFAULT_CREATE_SETTERS);
this.enableDecimalLogicalType = objects.property(Boolean.class).convention(Constants.DEFAULT_ENABLE_DECIMAL_LOGICAL_TYPE);
this.stringTypeProvider = getStringType()
.map(input -> Enums.parseCaseInsensitive(Constants.OPTION_STRING_TYPE, StringType.values(), input));
this.fieldVisibilityProvider = getFieldVisibility()
.map(input -> Enums.parseCaseInsensitive(Constants.OPTION_FIELD_VISIBILITY, FieldVisibility.values(), input));
this.classpath = GradleCompatibility.createConfigurableFileCollection(getProject());
this.logicalTypeFactories = objects.mapProperty(String.class, Constants.LOGICAL_TYPE_FACTORY_TYPE.getConcreteClass())
.convention(Constants.DEFAULT_LOGICAL_TYPE_FACTORIES);
this.customConversions =
objects.listProperty(Constants.CONVERSION_TYPE.getConcreteClass()).convention(Constants.DEFAULT_CUSTOM_CONVERSIONS);
this.stringTypeProvider = getStringType()
.map(input -> Enums.parseCaseInsensitive(Constants.OPTION_STRING_TYPE, StringType.values(), input));
this.fieldVisibilityProvider = getFieldVisibility()
.map(input -> Enums.parseCaseInsensitive(Constants.OPTION_FIELD_VISIBILITY, FieldVisibility.values(), input));
this.projectLayout = getProject().getLayout();
this.resolver = new SchemaResolver(projectLayout, getLogger());
}
Expand Down

0 comments on commit 1947802

Please sign in to comment.