Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make property specs independent of tasks #8231

Merged
merged 36 commits into from Jan 18, 2019
Merged

Conversation

wolfs
Copy link
Member

@wolfs wolfs commented Jan 14, 2019

No description provided.

@wolfs wolfs self-assigned this Jan 14, 2019
@wolfs wolfs requested a review from lptr January 14, 2019 14:19
@wolfs wolfs force-pushed the wolfs/extract-property-specs branch 2 times, most recently from ac1b4b5 to 576cff9 Compare January 15, 2019 08:11
Copy link
Member

@lptr lptr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving things around and making several changes to them at the same time makes it really hard to review this change as is. Would there be a way to split this up into two or more smaller chunks? Just getting rid of the SpecFactory would be a nice first step. Or does that pull in everything with it?

public abstract class AbstractInputPropertyAnnotationHandler implements PropertyAnnotationHandler {
import static org.gradle.api.internal.tasks.properties.annotations.InputPropertyAnnotationHandlerUtils.isOptional;

public abstract class AbstractInputFilePropertyAnnotationHandler implements PropertyAnnotationHandler {
@Override
public boolean shouldVisit(PropertyVisitor visitor) {
return !visitor.visitOutputFilePropertiesOnly();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bothers me. Why do we need this? Why can't simply PropertyAssociationTaskFactory.Listener do nothing when visitInputProperty() etc. is called? We are breaking, or at least complicating the visitor pattern by adding quite a bit of code in order to return early instead of executing some no-op stuff. I might be missing something, but this looks like the wrong thing to do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, that is a performance optimization introduced by @adammurdoch so we don't have a performance regression for attaching the producers. The performance regression was caused by going into the nested properties. See

private static class Listener implements PropertyVisitor {
private final Task task;
public Listener(Task task) {
this.task = task;
}
@Override
public boolean visitOutputFilePropertiesOnly() {
return true;
}
@Override
public void visitInputFileProperty(String propertyName, boolean optional, boolean skipWhenEmpty, Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
throw new UnsupportedOperationException();
}
@Override
public void visitInputProperty(String propertyName, PropertyValue value, boolean optional) {
throw new UnsupportedOperationException();
}
@Override
public void visitDestroyableProperty(Object value) {
throw new UnsupportedOperationException();
}
@Override
public void visitLocalStateProperty(Object value) {
throw new UnsupportedOperationException();
}
@Override
public void visitOutputFileProperty(String propertyName, boolean optional, PropertyValue value, OutputFilePropertyType filePropertyType) {
value.attachProducer(task);
}
}

It would be better to be able to attach the producer to outputs in nested beans as well. I'll check again how big the regression is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wolfs wolfs force-pushed the wolfs/extract-property-specs branch from a9b7d4e to a93e431 Compare January 15, 2019 13:36
Declared -> Registered
Move ValidatingValue to properties package
Looks like 0.4.1 is using `TaskValidator`.
The value doesn't validate any more.
Since validation happens separately now, we don't need to wrap the
value.
The method is so simple it makes no sense to extract it.
@wolfs wolfs force-pushed the wolfs/extract-property-specs branch from a93e431 to f9cdfbe Compare January 15, 2019 14:00
@lptr
Copy link
Member

lptr commented Jan 16, 2019

  • PropertyMetadata.getFieldName() should be getPropertyName()
  • DefaultFilePropertySpec doesn't need to implement Comparable<PropertySpec> explicitly

@wolfs wolfs force-pushed the wolfs/extract-property-specs branch from 529444b to ed1dde1 Compare January 16, 2019 18:05
@wolfs
Copy link
Member Author

wolfs commented Jan 17, 2019

@lptr I addressed your comments. PTAL!

@wolfs wolfs force-pushed the wolfs/extract-property-specs branch from ed1dde1 to e94630d Compare January 17, 2019 08:32
public void visitOutputFileProperty(String propertyName, boolean optional, PropertyValue value, OutputFilePropertyType filePropertyType) {
addCanonicalizedPaths(
public void visitOutputFileProperty(final String propertyName, boolean optional, final PropertyValue value, final OutputFilePropertyType filePropertyType) {
reportDeadlockOnParameterResolution(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method name sounds like we already know there will be a deadlock. It should be more like something withDeadlockHandling() or something. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to withDeadlockHandling.

Let's do the whole rename at once instead of piecewise.
@wolfs wolfs merged commit aaa71c9 into master Jan 18, 2019
@wolfs wolfs deleted the wolfs/extract-property-specs branch January 18, 2019 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants