Force IntelliJ to rerun anntoation processors? - intellij-idea

Is there any way to rerun annotation processors without rebuilding the entire project?
I'm developing an annotation processor which is used in project that takes ~ 10 minutes to build from scratch and it's a bit painful to wait 10 mins to test a change...

General Aspect
This sounds like you don't have a proper testing approach for your annotation processor.
If you do testing always in an integrated environment, you will always have the problem of long running tests. This applys to any test environment that depens on heavy task.
So, my generall advice would be to write lightwight unit tests to check you code is working as expected. That's a general advice I can give you.
This article https://blog.jooq.org/2018/12/07/how-to-unit-test-your-annotation-processor-using-joor/ from Lukas Eder - the founder of JOOQ and that uses java annotation processors as well - is about unit testing java annotation processors.
Only Run Annotation Processors
Intellij Idea
AFAIK there is no way to do this.
Maven
If your project runs on maven, you can trigger annotation processors by just execution the generate-sources phase.

Annotation processor can not be run without the compiler.
If you are not using Maven or Gradle to build the project but is using the IDE's build, invoke the Build | Build Project action. This way IDE will perform an incremental build that will build only changed classes.

Related

#QuarkusTest unit tests take a long time

I started a project and have about 7 tests in my project now and it takes already more than a minute to execute the whole test suite using gradle test.
From the additional output (--info flag) I can see that the whole quarkus application and also dependencies like the mongodb instance are restarted for every test class and method.
This is the exact opposite of what the quarkus documentation says on the testing guide page:
So far in all our examples we only start Quarkus once for all tests. Before the first test is run Quarkus will boot, then all tests will run, then Quarkus will shutdown at the end. This makes for a very fast testing experience however it is a bit limited as you can’t test different configurations.
All the tests are annotated with #QuarkusTest and every test just tests a single endpoint.
I use "pure" kotlin (1.5.21), Quarkus version 2.2.2.Final and gradle 6.9.
Installed features: cdi, config-yaml, jacoco, kotlin, mongodb-client, mongodb-panache-kotlin, narayana-jta, rest-client, rest-client-jackson, resteasy, resteasy-jackson, smallrye-context-propagation, smallrye-health, smallrye-openapi, swagger-ui
Is that a normal behaviour? If yes, an application with multiple hundred tests could easily take ~20 minutes or more to run the entire test suite.
I didn't try out maven yet, so I can't verify that it's not a gradle related issue.
While trying to reproduce it with a fresh project, I think I found the issue with my code:
I also used #QuarkusTestResources with restrictToAnnotatedClass=true on my tests.
This means the configuration & test profiles must be reloaded and therefore also the quarkus application.
Apparently all the DevServices get restarted, too (in my case it was a mongodb, since I'm using the panache extension), which explains the long runtimes of the tests.
I reorganized my tests a little bit, so they work with the "global" test resources (it was a WireMockServer in my case).
Now quarkus only gets started once before the tests and the total runtime of the gradle test task is acceptable.

What is Gradle build system in Kotlin?

I was reading the Kotlin documentation and I came across the statement,
By default, your project will use the Gradle build system with Kotlin DSL.
What does it mean?
I've seen Gradle Kotlin option while making a new project in IntelliJ:
Can somebody explain me these, and which Bundle I should be using as a beginner?
A build system combines and simplifies some of the key tasks involved in building and distributing your program. The main things a build system does include:
Downloading any dependencies your application has
Running tests against your application
Compiling your code
Packaging up your application and its dependencies into a form you can share with others
You could run all of these tasks separately yourself, but build systems make it a lot easier and less prone to mistakes. In practice, all but the smallest projects use some kind of build system. Gradle is one such tool, but you can also use Maven, or the tools built into an IDE like IntelliJ.
Which one should I use?
If this is a personal project, the build system and tools built into an IDE like IntelliJ are more than good enough.
If you're working with other people, you might want to consider a standalone build system instead. That's because standalone build systems like Gradle can be used with multiple IDEs, and can also be used on the command line without an IDE at all. Large projects with many contributors will often run a build server that runs the build system in an automated way against all new changes, to make sure the code builds and runs as expected.
IDEs like IntelliJ have very good integration with the common build systems, including Maven and Gradle, so you won't disadvantage yourself by choosing them over the built-in IDE tools.
Maven, Gradle, or Gradle with Kotlin?
There are plenty of other resources you can find comparing Maven with Gradle. The crucial difference, though, is the way you write the build script that allows you to customise the dependencies, tests, and other parameters of your build.
In Maven, your build script is an XML file. It follows a rigid structure, providing inputs and configuration to existing tasks and plugins.
In Gradle, the build script was historically written in Groovy, a loosely-typed language that gives you a lot of flexibility. As well as configuring tasks and plugins, you can easily add your own tasks and functions.
You can also choose to write Gradle build scripts in Kotlin. This offers the same flexibility and customisation as Groovy, but the addition of a type system means the IDE can give you much more help with writing the script correctly.

Use RAM with gradle and IntelliJ Idea

Currently, I'm using gradle as our production java builder and it's slow.
I was thinking is there a way to set-up some kind of RAMdrive working directory, so compiling, building, testing, and running would be much faster and the source code would remain on HDD.
Ideally, if I could tune it in my IDE somehow (maybe IDE internal gradle options).
I have initialized a RAMdrive but stuck in gradle :) Any ideas?

Play framework 2.0 continuous integration setup

I am looking for ideas for a Play 2.0 continuous integration setup. It would contain typical jobs like build after a git push, nightly builds with deployment to a test Heroku instance etc. Also code quality and test coverage metrics generation would be handy.
At the moment the stack looks like Play 2.0 with Java but that might change to Scala.
For "traditional" Java web app I would use Hudson/Jenkins. I found a Hudson plugin for Play but it doesn't seem to support Play 2.0. Is Hudson suitable tool here in general or what is your setup for Play 2.0 applications?
Play 2.0's build tool is just a thin wrapper around SBT. You should be able to use Hudson's sbt plugin to execute SBT build commands that are the equivalent of the Play commands you would execute from the console.
We execute the following under Bamboo for our builds:
SBT_OPTS="-Dsbt.log.noformat=true"
sbt clean compile test
(The SBT_OPTS variable turns off the colour formatting, making test output legible in log files.)
I found useful to add JUnit reporting plugin as I couldn't get test results to be displayed otherwise.
https://github.com/bseibel/sbt-simple-junit-xml-reporter-plugin
For PMD and Checkstyle I used this:
https://github.com/ymasory/sbt-code-quality.g8
For test coverage I am using JaCoCo at the moment:
http://ronalleva.com/2012/04/25/jacoco-and-play.html
Scct could be other option for coverage: http://mtkopone.github.com/scct/
With those and PMD, CheckStyle and JaCoCo plugins for Jenkins I have now quite ok setup for a Play 2 Java project.
here Is some detailed tutorial about doing It
http://wiki.cloudbees.com/bin/view/DEV/Playframework
It based on cloudbees but it would work fro any Jenkins Installation
You actually don't even need to use the SBT Plugin. I am running Play 2.1.1 on Jenkins and simply use the Execute Shell. I run something like the following:
cd ./your-play-project-root
play clean compile test stage
exit
This works quite well. "play" is simply just a thin wrapper around sbt.
"stage" will create a runnable in your target/server directory. Then, you can simply shell again to actually start your play application!

How make Eclipse instrument classes at build time?

Sometimes I have to perform some custom bytecode transformation.
I have used mainly asm and javaassit.
Inside eclipse usually I run my code with the -javaagent jvm parameter. Outside eclipse I use maven, ant, or the command prompt to invoke the weavers before running the application code.
But the point is that: I would like to perform instrumentation at build time inside eclipse.
What is the best way to do it?
Is there an already made plugin that I can connect to by implementing some api?
May I script this with eclipse monkey?
May I use an ant builder and invoke my weaver with it?
Should I look at the AspectJ plugin (must be huge) and try to figure out how to make my own plugin?
Should I look at the some other plugin to get inspiration?
Thanks.
You can create an annotation processor. This way you will be able to use it with ant, maven and any IDE (not only Eclipse).
Here is an example:
http://java.dzone.com/news/using-java-6-processors