Could not load compiled classes for initialization script from cache - gradle

So i ran a java program in IntelliJ using Gradle for 2 hours and then my computer (which has Windows as its OS) didn't work correctly so I had to restart it. But then this problem occurred when building my Gradle Project, where it told me that it "Could not load compiled classes for initialization script from cache".

Solution moved from question
The solution is really simple but it took me a long long time to figure it out so I wanted to share it with anyone who might also stumble across this problem (I also haven't seen a simple solution elsewhere).
Step 1: Open the Explorer and go to "C:/Users/username/.gradle/caches" (if you don't see the .gradle folder in your file explorer you have either moved it to a different directory or you have to enable the ability to view hidden folders in your file explorer: https://support.microsoft.com/en-us/windows/view-hidden-files-and-folders-in-windows-97fbc472-c603-9d90-91d0-1166d1d9f4b5 , I don't mean the .gradle folder inside your IntelliJ project but the Gradle user home directory which you can find in IntelliJ by clicking "File > Settings > Build, Execution, Deployment > Build Tools > Gradle")
Step 2: delete everything inside the caches folder (in other words, clear the Gradle cache)
Step 3: start IntelliJ and rebuild your Project with gradle
I did that and then my gradle Build worked again perfectly and I could run my code again. I hope it helps :)!

Related

How do I fix "No Main Classes Found" message in Netbeans for JavaFX 11 project?

I have a JavaFX 11 Maven-based project that I created in Netbeans 11.3. Everything was working fine (building and running the project). Last night, after restarting Netbeans, I can no longer run the project. When I attempt to run it, I am presented with the "Select Main Class for Execution" dialog, which informs me that "No main classes found", with no way to specify one.
I do have a proper main class.
If I edit the project Run settings, and try to browse for the main class, I get the same message: "No Main Classes Found".
I am at a loss on how to resolve this.
When I set up this project I did follow the JavaFX 11 getting started steps for Netbeans, Modular project, with Maven, here: https://openjfx.io/openjfx-docs/
in Netbeans, try to:
Copy your current code (or back it up in a different location)
Delete your current file
Create a new main class in your project (you can name it the old
one)
Paste your code back in
If this doesn't work then try to clear the Netbeans cache, and if all else fails, then just do a clean un-installation and re-installation of Netbeans.

SpringBoot Kotlin project wont run and debug from Intellij

We have inherited a SpringBoot project written in Kotlin. Using Intellij, I would expect to be able to go to the Application main method and click the green arrow to start the project. I would also expect to be able to run the project in debug mode and set breakpoints, this only works with tests.
When I try and run the project I get a exception FileNotFound which has yielded me no answers. Every file appears to be accounted for and there is clearly nothing missing.
This is a multi-module gradle project with many unique configurations and I suspect one is causing an issue. I am having trouble determining which configuration is causing the issue because the project doesn't even seem to get to the point of standing up Spring (no banner).
I have tried many different combinations of bash scripts, environment variables, and gradle tasks and the project does not seem to run at all. Is there any way I can use Intellij to debug the sequence of configurations and gradle tasks?
So, I am answering my own question because searches lead me nowhere and this was a surprisingly difficult problem to debug. It turns out I was taking the wrong approaches and asking the wrong questions. I took a lot of time to study up on Spring configurations and Gradle tasks to realize none of our stuff was wrong. The Kotlin compiler was failing at the very beginning.
What had happened was one developer naively cd'ed into the Application's module and ran an echo statement that piped gradle output to a file called out with no extensions.
Kotlin would find this file and then proceed to not compile anything starting at the Application main. When we ran the app from terminal the app would recompile itself from the very beginning with no problems. But the automatically generated Intellij config simply ran the app with the bad file every time.
The troubling part was that our .gitignore file was configured to ignore all of the kotlin /out/ directories, but not files like /out so this troublesome file was committed to the repository for quite a while.
Surprisingly, deleting this out file fixed most of the issues our project had with Intellij.
Another note:
Our script was also set to source certain variables from other scripts, which meant we either had to carry them over to the runtime configs. We could also run Intelli from the same terminal we had already sourced the script in (using Tools> Create command line launcher). Once I had that sorted the project ran and debugged perfectly.

Why does TFS build is not running tests as if it don't exist?

I have recently added a TFS build to our project, and configured it to run the automated tests that are in the project, and for some reason the build is ignoring the tests as if they don't exist!
In order to figure this out I created another solution with only a basic project from the origin code and the test project as well.
I've added these to the TFS and configured an almost equal build to this solution, and guess what? it executed the tests! it's the same tests as the original. just a copy of it.
The main difference between these 2 solutions is that the original code is a big solution with many projects, most of the projects are in some kind of a solution directory (and so does the tests project - it's inside a solution directory as well).
The difference between the TFS build definition is only that the output location of the build is set to single directory (I also tried PerProject and it worked) and in the original code it's defined to "AsConfigured" because we have some build tasks for copying dlls and such.
Has anyone encountered this problem?
Any ideas?
Thanks
TFS will look for the test DLLs in the BINARIES output folder location. You need to configure your 'build tasks for copying DLLs' to ensure your test DLLs are copied to this location.
Test assembly file specification
Specify the binary files that contain the tests that you want to run. Leave the default value (**\**test*.dll) if you want the build agent to search recursively for any .dll files that match *test*.dll in the binaries subdirectory of the build agent's working directory.
TFS2013 — http://msdn.microsoft.com/en-us/library/ms253138.aspx
TFS2012 — http://msdn.microsoft.com/en-us/library/ms253138(v=vs.110).aspx

TeamCity Dependency not sticking around

I'm sure this is a dumb mistake on my part but I can't find the right answer.
I have a project that has a snapshot dependency on another project. For sake of discussion website is dependent on toolkit.
Monitoring the build folder:
c:\programs\Teamcity\buildagent\work
I see the toolkit get built and the folders all exist as expected:
c:\programs\teamcity\buildagent\work\toolkit
Then the website build kicks off and the folder above gets deleted before the website build starts.
This results in the website saying the reference couldn't be found. What setting am I missing?
Using TeamCity 7.1.2, working on getting it upgraded to 8.1 but it requires some internal evaluation first.
Don't think its a version issue. How do both of your builds know where to put the artefacts at . For ex teamcity normally builds stuff at c:\programs\teamcity\buildagent\work****\toolkit , not at c:\programs\teamcity\buildagent\work\toolkit ?
Also, if your targets are dependent upon each other across builds, (1) have you setup any artefact dependencies or (2) any process that does not read of a shared agent workspace ? or (3) forcing both builds to run from the same directory
See if both your builds are running on the same target "folder name". In case they are , deselect any option that "cleans up build targets" before they run.
Also, you might want to check your build files to see if they have any code to clean directories before they start to run

Compiling Apache Hadoop Source in Eclipse

After about 4 tries I've managed to use git to checkout apache's Hadoop source code, issue a
mvn eclipse:eclipse
command and then import all of the projects into eclipse. So far this has been the most successful I have been. I am ALMOST there. I attempted to build and clean all projects and everything was going well. Now I only have 3 errors to get rid of. I would be EXTREMELY appreciate if anyone could help me with this. I have been trying to get this to work for about 2 days or so. Anyway, in Eclipse I have about 20 Hadoop projects. There are only two that have errors. One is called "hadoop-streaming" and the other is "hadoop-tools-dist."
The error says the following:
Project 'hadoop-streaming' is missing required source folder: 'C:/Users/User/hadoop/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf'
The other errors are mainly related to this one. That's what Eclipse says anyway. I tried to copy the folder to where it was needed but that didn't clear up the error. Does anyone know how to fix this? If you need anything from me just ask.
I don't know how the Hadoop project looks like, but I suppose that it is using maven. So instead of using the
mvn eclipse:eclipse
I would suggest using the import functionality of eclipse -> import maven projects (even though sometimes works harder than one might expect). Related to your issue, this kind of error occurred to me whenever there was some kind of folder that is not added as source folder in eclipse (generated folders for source etc.). So, I would advise checking that the folder you mentioned is already there and if it is added as a source folder. If not, just mark it accordingly (source folder). Clean the project (Project > Clean...) and if need update the maven project(Right click on the parent project > Maven > Update project ...)
Good luck!
In eclipse:
right click on the hadoop-streaming program
select Properties
On the left side of the bar,click Java Build Path button,then select source lable page
delete the path that went wrong
click Link Source
select the linked directory as (your hadoop-src root path)/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/conf
click Next button, inclusion patterns add capacity-scheduler.xml,exclusion patters add **/*.java

Resources