aaschmid / gradle-cpd-plugin

Gradle plugin to find duplicate code using PMDs copy/paste detection (= CPD).
Apache License 2.0
95 stars 12 forks source link

Worker API follow up #35

Closed larsgrefer closed 5 years ago

larsgrefer commented 5 years ago

This PR is a continuation of #32

aaschmid commented 5 years ago

Problem was that properties of Cpd*FileReportImpl - which are used by Gradle - are not serializeable in the end. Therefore I build a mapping to simple DTOs for them.

Now a java.util.ServiceConfigurationError appears in most unit tests :-( Even though integration test work, packaging the plugin and use it another projects fails it...

java.util.ServiceConfigurationError: net.sourceforge.pmd.cpd.Language: Provider net.sourceforge.pmd.cpd.CPPLanguage not a subtype
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at net.sourceforge.pmd.cpd.LanguageFactory.<init>(LanguageFactory.java:27)
    at net.sourceforge.pmd.cpd.LanguageFactory.<clinit>(LanguageFactory.java:16)
    at de.aaschmid.gradle.plugins.cpd.internal.CpdAction.run(CpdAction.java:78)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:39)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:25)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$WorkerCallable.call(IsolatedClassloaderWorkerFactory.java:177)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory.executeInWorkerClassLoader(IsolatedClassloaderWorkerFactory.java:105)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory.access$100(IsolatedClassloaderWorkerFactory.java:54)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$1.call(IsolatedClassloaderWorkerFactory.java:78)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$1.call(IsolatedClassloaderWorkerFactory.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.execute(IsolatedClassloaderWorkerFactory.java:75)
    at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:102)
    at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:96)
    at org.gradle.internal.work.AbstractConditionalExecution$1.run(AbstractConditionalExecution.java:38)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:212)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:161)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:130)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:748)
aaschmid commented 5 years ago

to be honest ... don't know if we currently have the proper way-of-work for this issue. What's your opinion to follow up?

I would like to create a new version with your other changes and maybe we should rebase all our changes on that? What do you think @larsgrefer?

Edit: Testing on other projects can be done easily by using something like

buildscript {
    dependencies {
        classpath files('../gradle-cpd-plugin/build/libs/gradle-cpd-plugin-1.2.jar')
    }
}
// ...
apply plugin: 'cpd'
larsgrefer commented 5 years ago

I'm not sure why you've already merged #32 since it was clearly marked as draft. I also wasn't finished with looking at all the comments you've made. In addition to that, I have not had time yet to fully test my changes.

aaschmid commented 5 years ago

First, I merged it, because I have had time on the weekend to work on it and it was looking quite promising to include it in the next version with the other changes. Second, to be honest, I wasn't sure if you were angry about all my comments and the delay ...

Sorry for the hasty things and the missunderstanding. Suggestion: So if you want, you can rebase your branch ('feature/workerApi') upon master, work on my comments from #32, and I will remove the 'use-worker' branch from this repo such that you have time to fix it all.

I will meanwhile create a new release with all the other changes if you don't mind?

Sounds like a plan or do you @larsgrefer have a different idea?

aaschmid commented 5 years ago

Hi @larsgrefer, I took your squashed commits (you are still the "author") and refactored my code and test test cases to get the "Gradle Worker API" running, see https://github.com/aaschmid/gradle-cpd-plugin/tree/use-worker-api. I very much hope that you are not pissed or angry by our missunderstanding :-( I am very sorry for that.

Thank you very much for your efforts!