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
Conversation
This brings PropertyValue closer to a basic ValidatingValue.
ValidatingValue is enough to capture the actual value.
Especially the annotation handler should not need the file resolver.
ac1b4b5
to
576cff9
Compare
There was a problem hiding this 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?
subprojects/core-api/src/main/java/org/gradle/api/tasks/TaskOutputFilePropertyBuilder.java
Show resolved
Hide resolved
...core/src/integTest/groovy/org/gradle/api/tasks/TaskInputFilePropertiesIntegrationTest.groovy
Outdated
Show resolved
Hide resolved
...ojects/core/src/main/java/org/gradle/api/internal/tasks/properties/UnitOfWorkProperties.java
Outdated
Show resolved
Hide resolved
subprojects/core/src/main/java/org/gradle/api/internal/tasks/properties/ValidationActions.java
Outdated
Show resolved
Hide resolved
...le/api/internal/tasks/properties/annotations/AbstractInputFilePropertyAnnotationHandler.java
Outdated
Show resolved
Hide resolved
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Lines 52 to 88 in 69efd80
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked it out, and there seems to be quite a performance impact: https://builds.gradle.org/viewLog.html?buildId=19160450&buildTypeId=Gradle_Check_PerformanceTestCoordinator&tab=report_project944_Performance&branch_Gradle_Check_Stage_ReadyforMerge=wolfs%2Fextract-property-specs-review
I would leave the code as is for now. Shall we add a card to clean it up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...core/src/integTest/groovy/org/gradle/api/tasks/TaskInputFilePropertiesIntegrationTest.groovy
Outdated
Show resolved
Hide resolved
subprojects/core/src/main/java/org/gradle/api/internal/AbstractTask.java
Outdated
Show resolved
Hide resolved
...ojects/core/src/main/java/org/gradle/api/internal/tasks/CompositeTaskOutputPropertySpec.java
Outdated
Show resolved
Hide resolved
subprojects/core/src/main/java/org/gradle/api/internal/tasks/TaskFilePropertySpec.java
Outdated
Show resolved
Hide resolved
subprojects/core/src/main/java/org/gradle/api/internal/tasks/properties/PropertyWalker.java
Outdated
Show resolved
Hide resolved
.../groovy/org/gradle/api/internal/project/taskfactory/TaskPropertyNamingIntegrationTest.groovy
Show resolved
Hide resolved
a9b7d4e
to
a93e431
Compare
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.
a93e431
to
f9cdfbe
Compare
subprojects/core/src/main/java/org/gradle/execution/plan/DefaultExecutionPlan.java
Outdated
Show resolved
Hide resolved
...ore/src/main/java/org/gradle/api/internal/tasks/DefaultRegisteredTaskOutputFileProperty.java
Outdated
Show resolved
Hide resolved
subprojects/core/src/main/java/org/gradle/api/internal/tasks/DefaultTaskOutputs.java
Outdated
Show resolved
Hide resolved
...ojects/core/src/main/java/org/gradle/api/internal/tasks/RegisteredTaskInputFileProperty.java
Outdated
Show resolved
Hide resolved
subprojects/core/src/main/java/org/gradle/api/internal/tasks/TaskPropertySpec.java
Outdated
Show resolved
Hide resolved
subprojects/core/src/main/java/org/gradle/api/internal/tasks/properties/InputPropertySpec.java
Outdated
Show resolved
Hide resolved
subprojects/core/src/main/java/org/gradle/api/internal/tasks/properties/InputPropertySpec.java
Outdated
Show resolved
Hide resolved
...le/api/internal/tasks/properties/annotations/AbstractInputFilePropertyAnnotationHandler.java
Outdated
Show resolved
Hide resolved
...ojects/core/src/main/java/org/gradle/api/internal/tasks/execution/DefaultTaskProperties.java
Show resolved
Hide resolved
...s/core/src/main/java/org/gradle/api/internal/tasks/properties/DefaultValidatingProperty.java
Outdated
Show resolved
Hide resolved
|
529444b
to
ed1dde1
Compare
@lptr I addressed your comments. PTAL! |
ed1dde1
to
e94630d
Compare
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
No description provided.