This message was deleted.
# plugin-development
s
This message was deleted.
v
Can you share your code? Especially the past where you schedule the worker?
t
https://github.com/wpilibsuite/deploy-utils/blob/54486e042560eb36ee480f0839f9d71f75068c2e/src/main/java/edu/wpi/first/deployutils/deploy/target/discovery/TargetDiscoveryTask.java#L74 The service itself is expected not to be serializable. There is an object I have to pass to the worker that will never be serializable. In the past I’ve used a static variable to handle this, and the documentation made it seem like build services could be passed without the need to be serializable.
v
Static state is always problematic, yes, because it will partially be available cross-build-runs and thus influence other build runs or in some cases even other projects built in the same Gradle daemon. Regarding your error, it is like I assumed, you are not following the docs you linked to yourself. It says:
To do this, pass the build service
Provider
as a parameter of the consuming action or service, in the same way you pass other parameters to the action or service. For example, to pass a
MyServiceType
service to worker API action, you might add a property of type
Property<MyServiceType>
to the action’s parameters object and then connect the
Provider<MyServiceType>
that you receive when registering the service to this property.
But what you do is to get the service from the provider and then give that instance to the worker, that will not work.
t
So it needs to be a property of a property? I guess that makes sense, but the docs are not super clear on that. In some places in the docs, I’ve seen this quote “ a property of type property ‘property<thing>” mean just a property<thing>, not a property<property<thing>>. So the docs are confusing there.
I’m hopeful this is finally a workaround to needing static state. I know it’s a problem, and can cause issues, but for our specific case we needed to pass an ssh context to the worker, and that will never be serializable. But if it’s a service and guaranteed to be build specific, that removes the static requirement and massively helps us.
v
No, not a property of a property. You are just doing the wiring wrongly
What you have is
Copy code
StorageService storageService = getStorageService().get();
getWorkerExecutor().noIsolation().submit(TargetDiscoveryWorker.class, config -> {
    config.getStorageService().set(storageService);
}
What you need is
Copy code
StorageService storageService = getStorageService().get();
getWorkerExecutor().noIsolation().submit(TargetDiscoveryWorker.class, config -> {
    config.getStorageService().set(getStorageService());
}
You need to wire the provider to the provider and not give the actual instance to the provider.