Open zhiyufan opened 3 years ago
Hi @zhiyufan
From the Getting Started document, I didn't see any description about Gradle.
Astor is not capable of automatically determine the dependencies and structure (e.g., folders with the src/binaries) of a Gradle project. However, you can execute Astor on Gradle project by passing that info using via parameters (-dependencies, -srctestfolder, etc ) as you have done.
java -cp $(cat /tmp/astor-classpath.txt):target/classes fr.inria.main.evolution.AstorMain -mode jgenprog -srcjavafolder /src/java/ -srctestfolder /src/test/ -binjavafolder /build/classes/main -bintestfolder /build/classes/test -location /home/zhiyu/astor/examples/mockito_22/ -dependencies examples/mockito_22/lib "
I think the problem is in the dependencies parameter has a relative path, but it should be an absolute path
Thanks for the quick reply.
I have changed to absolute path, but the error is still there. "java -cp $(cat /tmp/astor-classpath.txt):target/classes fr.inria.main.evolution.AstorMain -mode jgenprog -srcjavafolder /src/ -srctestfolder /test/ -binjavafolder /build/classes/main -bintestfolder /build/classes/test -location /home/zhiyu/astor/examples/mockito_22/ -dependencies /home/zhiyu/astor/examples/mockito_22/lib"
Also, I don't understand what does this error means "spoon.compiler.ModelBuildingException: The import org.mockito.cglib cannot be resolved at /home/zhiyu/astor/examples/mockito_22/src/org/mockito/internal/creation/jmock/ClassImposterizer.java:7 at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.report(JDTBasedSpoonCompiler.java:635) at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.reportProblems(JDTBasedSpoonCompiler.java:617) at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:116) at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:97) at fr.inria.astor.core.manipulation.MutationSupporter.buildModel(MutationSupporter.java:85) at fr.inria.astor.core.manipulation.MutationSupporter.buildSpoonModel(MutationSupporter.java:253) at fr.inria.astor.core.solutionsearch.AstorCoreEngine.initModel(AstorCoreEngine.java:776) at fr.inria.main.evolution.AstorMain.createEngine(AstorMain.java:113) at fr.inria.main.evolution.AstorMain.run(AstorMain.java:173) at fr.inria.main.evolution.AstorMain.execute(AstorMain.java:233) at fr.inria.main.evolution.AstorMain.main(AstorMain.java:204)"
It seems that spoon cannot parse the program correctly?
It seems It cannot compile the code as it's missing one library: org.mockito.cglib.
Try to put the dependencies explicitly in the parameter, separated by File.pathSeparatior (e.g., :) -dependencies /home/x/x1.jar:/home/y/y1:jar
Hello @zhiyufan
Is the issue solved? Can I close it?
Thanks Matias
I am not sure if this is helpful, but I was able to run jgenprog with the Mockito 22 bug from defects4j. I did not use the example within the astor repository - maybe they are identical.
defects4j checkout -p Mockito -v 22b -w bugs/Mockito_22
java -cp astor.jar fr.inria.main.evolution.AstorMain \
-out output \
-mutationrate 1 \
-maxtime 240 \
-loglevel INFO \
-location bugs/Mockito_22 \
-mode jgenprog \
-srcjavafolder /src/ \
-srctestfolder /test/ \
-binjavafolder /target/classes/ \
-bintestfolder /target/test-classes/ \
-dependencies bugs/Mockito_22/lib/repackaged/cglib-and-asm-1.0.jar:bugs/Mockito_22/lib/compile/junit-4.10.jar:bugs/Mockito_22/lib/run/objenesis-2.1.jar
I get no error message though no patches are found.
I'm building a plugin for idea. It supports maven and gradle and is in active development these days. Now it can execute Astor with proper arguments and show diff of the best patch.
@qiujiangkun PR are welcome. In case you want to integrate the plugin's code into the main project, please contact us.
It seems that it requires a new module to auto-configure these paths. Also the code shall be rewritten in Java to be used here. I'm glad to contribute if I had time.
Hi,
I'm wondering if Astor supports repairing gradle based projects. From the Getting Started document, I didn't see any description about Gradle. However, there is a project called Mockito_22 under the example/ folder. May I ask the command to repair Mockito_22 or other third-party Gradle-based projects? The command that I have tried on Mockito_22 is attached
I'm using java 8 as the environment
Thanks in advance!