Only build sources without building tests
已回答
I have a sources directory marked as the sources root, and a test directory marked as test sources root. Whenever I build via IntelliJ, both regular and test classes are compiled. This causes errors later on because I have a separate list of regular and test dependencies. How can I build only the classes in the source directory? I found https://intellij-support.jetbrains.com/hc/en-us/community/posts/206978485-build-jars-without-test-classes but there haven't been any updates since 2008.
I'm also interested in how to configure this for an artifact (i.e. when building the artifact, only include classes in the sources root).
请先登录再写评论。
Please see this post:
https://stackoverflow.com/questions/16784703/enable-partial-compilation-in-intellij-idea/16784855#16784855
Thank you for the prompt response Konstantin Annikov! Unfortunately that response doesn't quite address the issue I'm having, which is that test classes are being packaged into my artifact. Ideally I only want test classes to be compiled if I am running a test suite. If I want to build and run the artifact, I don't want test classes to be compiled, because that means my artifact requires test dependencies, which are not available outside of tests. This results in class loader errors, because weaving the compiled classes causes IDEA to load dependencies which are not available.
You may add the tests directory that you want to exclude to File | Settings | Build, Execution, Deployment | Compiler | Excludes | Add
But there is no option to perform that automatically. You can submit a feature request at YouTrack:
https://youtrack.jetbrains.com/issues/IDEA
Was this feature ever added? I can't find any evidence of it and it would be helpful
Hello,
Seems there were no requests on YouTrack for that. Only to exclude while build is executed from run configuration: https://youtrack.jetbrains.com/issue/IDEA-264739
You are welcome to create feature request.