Related
I'm trying to run a Gradle Task by double clicking it on Eclipse, but the task is greyed out and says "Cannot run tasks for included builds" if I right click it as you can see in the image below:
What's that supposed to mean? Suddenly I can't run tasks for no apparent reason when I was able a few hours ago.
My project is Liferay based. I'm under JDK 1.8 and Windows 10.
I tried restarting Eclipse, cleaning project, deleting .gradle folder, changing Gradle version to 4.10 and refreshing tasks but nothing changes.
Please consider the following (It works fine in my case):
Delete the project on eclipse (just check delete nested projects), do not delete the project on the disk
Go the the project on the disk, find and delete all .project files
Re-Import Liferay workspace on eclipse (File > Import > Liferay Workspace Project) and select your project folder
That did the trick ! Gradle tasks are now refreshed in green.
Posting this in case it helps anyone. For me, this problem arose when I added a new Java project and manually converted it to gradle and then added it as a sub-project.
Doing so changed the following line in /.settings/org.eclipse.buildship.core.prefs from this:
connection.project.dir=
to this:
connection.project.dir=mynewproject
Once I changed that line back, I could run all sub-project tasks again.
My project was set up as a Gradle multi-project. I found that the build tasks for the parent and nested projects were greyed out. The fix was to remove the Eclipse Gradle Project Nature ( Project Natures -> Gradle Project Nature) project nature on the parent project, delete the .gradle folder of the parent project and then add the Gradle Project Nature again via Eclipse.
I think I found a solution, in case someone's having the same problem:
Copy project folder into another place
Delete project on Eclipse (check "Delete project contents on disk")
Delete .gradle folder inside the project folder
File > Import > Existing Gradle Project
Look for the project folder
Now you should be able to run Gradle Tasks again.
I hope this helps ;)
I am new to github. I tried to clone a repo and then pull the files on my computer. All the other team members did the same thing and it worked for them. When i open the project with Intellij all the .java files look like this:
files
It also says that my SDK isn't set.
I tried to set my SDK, and also i tried to set the java directory as 'sources root' because someone said that is a problem with the project structure.
These problems disappeared but then IntelliJ didn't recognize that my project is a maven project so i had to add manually the file pom.xml and refresh maven.
Then this problem disappeared but i had another:
"Cannot start compilation: the output path is not specified for module 'cmsiss'.
Specify the output path in Configure Project."
I tried to set it from project structure but now I have this error:output error
Please help.
Open maven project using pom.xml file. File->Open->pom.xml
Sources should be pointed to project root, not java directory.
Give these a try.
The usual steps that I follow to open the project:
git clone <github clone url>
Open the project in intelli J using
File<Open
and browse to open the root of the project.
This should work fine but if it does not, a few more things you can try:
Try making the project root as a maven module
You can open the Project Structure to make sure you have Java SDK set up properly. It should show the java version you are using there.
Worst case, that is if nothing else works and if the project is not too big, just create a new maven project and make sure it runs, then add all the project files.
I pulled the project again and started from zero. I specified the SDK and then I opened the Maven project window and added a maven project (selected the pom.xml file) and refreshed it. Maven did it's job and created the project structure and all the stuff I've tried to do manually and finally worked!
I'm trying to use the barbecue barcode printing library. I have successfully added the library to IntelliJ through project structure add library. Then I imported the packages and wrote the methods, which gave me no error. The packages were available in the class.
But when I compile it gives me the error:
error: package net.sourceforge.barbecue does not exist
How can this be?
I'm coding in ubuntu, is there any other place to which I have to add the library?
Just reimport didn't work. Following worked for me.
File -> Invalidate Caches /Restart
Then
Build -> Rebuild Project
That will reimport maven project.
Note : You need to invalidate the cache AND ALSO rebuild the project.
I tried to "Maven > Reimport" but the only thing that actually fixed it was to close the project, delete the .idea directory, and reopen the project.
None of the 13 existing answers worked for me. However, I could resolve the issue by first removing all modules:
open File > Project Structure...,
go to Modules tab,
select all modules and press the remove button,
then removing all remaining Maven modules from Maven tool window:
select all modules,
right click on them,
press Remove projects,
and then adding them again in Project tool window:
right click on root pom.xml,
press Add as Maven project,
now unignoring any ignored modules from Maven tool window:
select all ignored (grey) Maven modules,
right click on them,
press Unignore,
and finally rebuilding using Build > Rebuild project. This assumes that a mvn clean install already happened.
Right click your project / Maven (at bottom) / Reimport
Edit, much later: I also saw this happen much more frequently when I had the Clover plugin installed. Drop that plugin like a bad habit!
In my case the only thing that worked is:
mvn idea:idea
The good thing is that you don't have to delete .idea folder or .iml files and loose all configuration. Everything will be preserved.
(Possibly something like gradle idea works for gradle too).
menu -> build -> Rebuild Project
has worked for me
(Invalidating caches without this step doesn't help)
I did re-import all maven projects. This worked for me.
If you added a library to the project structure (rather than via maven, that would be different), be sure it is included as a dependency for the relevant module.
Project Structure -> Modules -> Dependencies
It's a very annoying problem which happens quite often. Especially after switching to a different git branch. It wasted me way too much time to troubleshoot this kind problem. I have tried all the methods above. But I can't find a reliable way. Here I just summarize those steps which could help in my situation. Jetbrains, please fix this issue to save your customer's precious time.
Make sure do a success command line build (If UT failed, please ignore UT by using -Dmaven.test.skip=true.
In the "Maven Projects" view, try to use "reimport" all the maven project.
In the file menu, use "Invalidate Caches"
Delete .idea folder, basically create the workspace from scratch. (That's the only reliable way can solve this issue)
In my case the problem was that there was a different repository directory configuration in IntelliJ and in settings.xml file.
Check both repository directories are the same:
IntelliJ (File > Settings > Build,Execution,Deployment > Build Tools > Maven )
settings.xml
(usually in C:\Users\myuser\.m2 or /home/myuser/.m2)
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<localRepository>C:\Users\myuser\.m2\repository</localRepository>
...
</settings>
After fixing directories run:
Generate Folders and Update Sources for All Projects
Reimport all maven projects
Tried all the above approaches, didn't work.
Finally running maven clean install solved it!
Quit IntelliJ, remove every .idea directory:
rm -Rf **/.idea/
and restart.
Invalidate Caches/ Restart and then Build -> Rebuild Project helped for me
I tried all appreciated answers and none of them solve my problem!
According to Intellij community, there is a bug with Maven builds in 2020.1 and 2020.1.1 versions: https://youtrack.jetbrains.com/issue/IDEA-237320?_ga=2.235486722.203129946.1591253608-322129264.1584010541
Please try to run on 2019.3.4 version (Its worked for me from the first time)
You can download from here
https://www.jetbrains.com/idea/download/previous.html?_ga=2.190043688.203129946.1591253608-322129264.1584010541
Similar to cvdr. Too high a Java version can be the problem.
A collegaue just have this problem with multiple java sources in our test project. She had just updated to a later Intellij and when we investigated none of the rebuild options worked but Intellij seemed to have 'bumped' the project Java settings to Java 11 (I guess it takes highest installed version on upgrade install?) Setting it back to Java8 and the project compiles successfully.
Go File>Project Structure > Project Settings > Project and select the right ones in the drop downs.
I got this error after I changed pom, and I fixed it by execute:
mvn idea:module
it works for me
Here is a solution worked for me:
Disable the "Use --release option for cross-compilation like the following in intellij idea:
got Settings -> Build,Execution,Deployment -> Compiler -> Java Compiler and disable:
Use '--release' option for cross compilation(java 9 and later)
As someone who only occasionally needs to do Java work, this was very annoying. Inevitably, packages would have been added since the last time I ran our server inside IntelliJ and it would fail to build. I found what seems to be an easier solution: just don't build within IntelliJ. Build from the command line via Maven, then make sure that the run configuration does not list Build as a "Before launch" task.
I tried
"Maven > Reimport"
Deleting the .idea directory, and reopening the project.
File -> Invalidate Caches/Restart then Build -> Rebuild Project
Deleting what is inside local .m2 folder, and downloading dependencies again.
Running mvn idea:idea in Maven console (Though this command is obsolete, I had to try.)
in different combinations.
But going from Intellij 2020 version to 2019 solved my issue.
I had this problem in IntelliJ 2020.3 and tried the invalidate cache option and rebuild, but the problem persisted. The only thing that fixed it was to rename the package and rename it back to what it was originally.
I had the same problem and it was fixed for me by changing the "Maven home directory" in Settings from "Bundled" to my locally installed maven. Perhaps this triggered some kind of refresh somewhere since I had not changed this setting for months without any issue.
What happens here is the particular package is not available in the cache. Resetting will help solve the problem.
File -> Invalidate Caches /Restart
Goto terminal and build the project again
./gradlew build
This should download all the missing packages again
If you are trying the suggested ways and still no chance, be sure about your order:
Delete your .idea/
Invalidate and Restart Cache afterwards
Import maven projects from your maven tool
If you did not invalidate and restart cache just after deleting your .idea/, Intellij keeps generating it and that was keeping error in my case.
I had the same issue with my unit tests. I created tests on my master branch and early everything worked well, no matter what branch I was using. But when I switched again to master branch, tests did not work anymore.
What helped me was to:
close intellij -> delete .idea file from directory -> open project again by pom.xml (idk if it matters what way you open the project, but first time when I tried to open it normally by intellij, it still dit not work) -> reload all maven projects from right menu -> rebuild project and that's it, everything works now
I had the same problem. I fixed it by applying the android-apt plugin https://bitbucket.org/hvisser/android-apt
Maven reimport, rebuild and invalidate caches did not work. I solved it by opening a terminal and executing maven clean install in the root folder project. (IntelliJ was opened and I was able to see the IDE updating and triggering reindexation while maven was doing his job)
The above solutions didn't work for me. I had to add the dependency explicitly in the pom.xml.
Just add your jar under resources/library and then add it as a dependency in your pom.xml like:
<dependency>
<groupId>your-jar-group-id</groupId>
<artifactId>artifact-id</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/library/name-of-jar.jar</systemPath>
</dependency>
Try this out if none of the above work.
Delete your .idea/
Invalidate and Restart Cache afterwards
Re-import project
If you do not want to destroy .idea, you can try :
open Project Structure > Modules
unmark the java folder as a source folder
apply / rebuild
then mark it again as a source folder
rebuild
In case you're facing very weird "unable to resolve java, sun packages problem", try the following:
Open Project Structure and change Project SDK to another version, example: java 8 -> 9; 11->13, etc, and wait until it re-index all jdk's jars. Switch between jdks with same version may not work! (Ex: jetbrains jdk11 -> openjdk 11)
Open a new project (or create a empty one); pause new project's indexing; close the old one; start indexing; open the old project and pause the new project's indexing and wait.
I checked out the existing project source code from SVN to a folder in my system.
Then I opened eclipse. Import Project-> Existing Maven Project.
It imported without issues. However, Project Explorer shows it as just folders instead of packages. (Like when we create a package and then add classes to it, it shows a different icon for package root). I opened Navigator and Package Explorer as well. But they are showing them as folders as well.
I tried:
mvn eclipse:clean
mvn eclipse:eclipse
on the root of the project. But it did not help.
Can anyone help on this one?
My folder structure:
ecs->
ecs-ejb->
src/java/main/com/xxx
pom.xml
ecs->ear->
src/java/main/com/xxx
pom.xml
pom.xml
Try to:
Right click the project->Configure->Convert to Maven Project
---- Edit ----
If this doesnt work, it is likely that someone checked in their environment files into your SVN. If they checked in:
.project
.classpath
.settings/
They could be conflicting with your environment (different settings/plugins/versions of eclipse...). Try dropping your project, deleting the folder/files, then remove these files from SVN, and repeat your initial process. All of these files/folders will get generated during the import to eclipse.
---- Edit 2 ----
Per your recent edit to the question, you have a multi-module project. If you only did this on the parent project, then there is no source folder. So you wouldn't see it. You should:
File->Import...
Choose Existing Maven Projects, Next
Set the Root Directory to ecs/ecs-ejb, Finish
Repeat for all other modules.
In eclipse, each module of a multi-module maven project needs its own eclipse project.
Right click the project->Configure->Convert to Faceted Form
This solution worked for me
Possibility is Module doesn't have .classpath.
Kindly right click on Module and Change Project fact as Java.
else
If you are using command Prompt.
1. mvn eclipse:clean
2. mvn eclipse:eclipse
else
Delete Project from Eclipse don't delete content from disk. remove .classpath and .project
Re-import as maven existing Project
Right Click->Maven->Update Project.
Above works perfectly fine for Eclipse Juno and solves the problem.
You just need to change the nature of the project.
For MAC->
-> Right click on project
-> Properties -> Check Project Natures
-> Then add or remove accordingly if you are having a maven project then add Maven, add Java
I had the same problem. I tried a lot of things that I read on internet but the only way that I found to solve my problem was exclude all of my workspace files (.metadata folder) and create another one.
After that, I imported a existing maven project and all my problems are gone.
I also faced a similar issue. I resolved it by downloading the correct apache maven plugins in the maven repository org / apache/ Maven/ plugins. IN my case, everything was working fine earlier and I had deleted .m2 repository completely. After that I started getting these issues with same iDE and newer IDE versions as well. The pom.xml showed error related to lifecycle mappings. On downloading the correct plugin, the workspace worked fine.
Delete the metadata folder. Checkout again but select "Checkout as a project configured using the New Project Wizard" instead of "Checkout as a project in the workspace".
Then a New Project wizard will open, type maven there and select "Checkout Maven Projects from SCM" preferably or "Maven Project". It should work. Remember this step should be performed for Maven Projects only. For normal Projects just select Java Project or whatever relevant type Eclipse project it is.
Check and make sure you have eclipse pointing at a Java JDK directory instead of a Java JRE directory.
I had just installed eclipse and only the JRE was in the settings. I added the JDK path, changed it to the default and clicked on Maven -> Update project. Then the packages appeared in Package Explorer.
The hint that helped me figure this out is that when I tried to use the refactor to rename a class, it wouldn't do it, complaining that it wasn't a JDK.
Instead of importing as Existing Maven Project, follow below steps
I assume that your folder has pom.xml, src/main and src/test.
Step 1: Right click > Create New > Java Project > Chose the project folder has pom.xml
Step 2: Right Click on Project > Configure > Convert to Maven project
I got it working using Proyect --> Properties --> Project Facets
In my case was a web project so I checked Java and Dynamic Web Module
Try right click on project, Maven->Update Project... (or similar, the link name changes depending on version)
This works for me when adding new folders, but I have not encountered the problem when importing a project.
Right click the project, then click Configure -> Convert to Maven Project. If the packages still display as ordinary folders, then right click on the folder one level up (the one that is supposed to be the source folder), then click Build Path -> Use as a source folder.
Here is my solution please close the Project Explorer at the left top and open again.
(or)
1). Right Click on your miscellaneous project and choose project Explorer if available.
Adding projects to working sets should help
try it ->
right click the project -> Maven -> Assign Working Sets... -> Add projects to working sets
I am starting to configure my development environment and I am using Spring Tool Suite 2.8.1 along with m2E 1.01.
As far as I can tell, since this is a Maven Project (my first), my Maven POM is dictating (along with m2E smarts) my project build configuration and dependencies.
What I would like to know is why my IDE is displaying Java Build Problems that read "Archive required for library library/path/somejar.jar cannot be read or is not a valid zip file" when I can see the jars in my .m2 repository?
All the errors pertained to commons-logging:1.1.1 which I excluded in my parent-pom. This was a transistive dependancy via spring-context-support:3.0.5. I excluded that library from my build and now the errors pertain to the spring-context-support library.
I have attached a screenshot to illustrate.
Indeed IDEs often cache the local repository (Eclipse does something similar, and I have to relaunch Eclipse).
One ugly maven behavior you might encounter is that if you declare a dependency before you actually install it, maven will create an empty version of the missing dependency (folder with metadata but no jar), and you will have to manually clean your .m2 repository.
Third, an installed archive (jar...) can get corrupted, so try to open it with any archive tool (7zip...) to test it, and delete the whole folder if the archive is corrupted.
In my case I had to manually delete all the files in .m2\repository folder and then open command prompt and run mvn -install command in my project directory.
I was using Eclipse as IDE and I was getting very same error. I had to do Project->Maven->Update Project. Select all the checkboxes below except "offline" esp. the one "Force update of snapshots/releases" and click OK. Did the Clean Build for the Project again.
Delete corrupted files from your local .m2 repository and Ctrl+F5 (Update Maven Project) in Eclipse/STS. It'll download and install these files.
This worked for me.
Close Eclipse
Delete ./m2/repository
Open Eclipse, it will automatically download all the jars
If still problem remains, then right click project > Maven > Update Project... > Check 'Force Update of Snapshots/Releases'
Below Steps resolved my issue.
Go to ./m2/repository folder.
Go to respective archive error folder.
Verify any zip file is exist.
delete error name folder.
Now come to Eclipse Project - Right Click - Maven - > Update Project.
Above trick works for me.
For Googlers:
In my case I had accidentally manually added a Java class to the build path while poking around Eclipse. By taking a look at the 'Configure Build Path...> Libraries I removed the culprit class and now only have the
JRE System Library
Maven Dependencies
and nothing is complaining.
In my case I tried all the tips suggested but the error remained. I solved changing with a more recent version and writing that in the pom.xml. After this everything is now ok.
I deleted the local maven repository.
Then just rightclick the project -> Maven -> Update Project...
Select all concerned projects and click OK.
I was facing the same problem with my project.
My project was not able to find this archive: -
C:\Users\rakeshnarang\.m2\repository\org\hibernate\hibernate-core\5.3.7.Final
I went to this directory and deleted this folder.
Went back to eclipse and hit ALT + F5 to update the project.
The jar file was downloaded again and the problem was solved.
You should try this.
This happens when Eclipse screws up. To fix it, delete all the files in:
workspace/.metadata/.plugins/org.eclipse.jdt.core
Remove maven dependenices from build path
I faced this problem. I had "Archive for required library spring-boot-devtools cannot be read or is not a valid ZIP file" and the solution was like that:-
1- determine the dependencies names that have problems(for may case it is spring-boot-devtools).
2- close eclipse.
3- search in your .m2 file on these dependencies(by name).
4- delete these folders.
5- reopen eclipse and let maven rebuild your dependencies again.
Ok, I had the same problem with STS on a mac and solved it by deleting all the files in repository folder and from the STS IDE click on the project and then Maven -> Update project. Give it a couple of minutes to download all the dependencies and the problem is solved.
I face with the same issue. I deleted the local repository and relaunched the ID. It worked fine .
Just had this problem on Indigo SR2. It popped up after I removed a superfluous jar from the classpath (build path). Restarting Eclipse didn't help. Added back the jar to the build path...error went away. Removed the jar once again, and this time I was spared from another complaint.
none of the solutions above helped my problem. I've resolved it by deleting all files in {projectworkspace}/.metadata folder AND in {location}/.m2 folder and let eclipse download every single thing again. Hope this helps someone, cheers!
When I got an error saying "archive for required library could not be read," I solved it by removing the JARS in question from the Build Path of the project, and then using "Add External Jars" to add them back in again (navigating to the same folder that they were in). Using the "Add Jars" button wouldn't work, and the error would still be there. But using "Add External Jars" worked.
This could be due to you have added spring-licence.txt file to your web app libraries.
I had similar issue and resolved after removing that text file. In libraries it will expect jar file only.
Alternatively, below commands also worked for me:
mvn -s settings.xml eclipse:clean
mvn -s settings.xml eclipse:eclipse
In case of VSCode, follow the below steps:
Navigate to the respective folder that contains the corrupted jar
Delete just the jar
mvn clean
mvn compile
That worked for me.
Read the issue in Problems section,identify which dependency not able to read, then go the maven repository .m2\repository ->
1)check the dependencies and delete it from the folder
2)go to STS/Eclipse -> click on maven -> update project ->select the force update of snapshots/releases and click on ok.
or
delete the dependencies from the .m2/repository and rebuild the maven --> update the maven project
In my case, I just had to remove the following 2 lines from proguard.cfg:
-keep class android.support.v4.** { * ; }
-dontwarn android.support.v4.**
Yes, I know that the question refers to the Spring Tool Suite but:
Spring Tool Suite is based on Eclipse (the IDE I am currently using for ADT).
Proguard is a Java obfuscator that can be used for any project, not just Android
I tried all the suggested answers and tips in the thread and none worked for me, until I removed the references to said libs.
I hope this helps someone.
Delete your C:\Users\PC\.m2** folder
and update maven project