I am working on my first project on maven in Eclipse IDE and encountered an error that says following
"could not resolve repository"
then I was instructed to delete .m2 folder and build it again.
How do I build it again ?
Your .m2 folder contains a folder repository and a setttings.xml (if you created one). The repository contains cached artifacts from the remote repositories and your own built artifacts. If you don't need the artifacts you have build any more, you can savely delete the folder repository. This might help you resolve problems with broken cache.
Related
I have a Maven archetype that I created myself from one of my projects and installed in my own local Maven repository. From Eclipse I am able to create new projects using this archetype and I obviously have access to the archetype's "installed" files (the ones that are placed in the repository after the install).
The problem is that now I want to share the archetype to a colleague, but after I created it and installed it to my local repository, I deleted the "installer" files (the ones that are generated in the generated-sources/archetype folder of my source project), so now I only have the archetype installed in my repository and I don't know how to export it in order to share it with someone else.
I could create a new archetype, but I put so much effort and spent several hours in doing that in the first place, so I would like to find out exporting the current archetype is possible, and if so, how can I do it?
EDIT
Asked in a different way, can I take the "installed" files from my local repository and put them in other repository, and have Maven recognize them as an Archetype?
What we ended up doing was to zip the repository archetype folder and send it to my colleague, who then performed these steps:
Unzip the archetype folder file to the root of his local Maven repository.
Execute the command ´mvn archetype:crawl´.
That was it. He was able to use the archetype for creating new projects.
I am new to intelliJ and trying to import maven projects. IntelliJ downloads all the jars from my local maven repo to the system/jars folder. Which is getting huge.
How can i make sure it does not copies the jar from local maven repo to system/jars folder instead should resolve dependency from the local maven repo only
Today I'v found that my system/jars folder is 6.6GB, maven dependencies which were updated are kept in jars folder even when not used.
Is there a possibility to clean this folder from old dependencies?
Also it would be better to use dependencies from local maven repo rather than making duplicates.
I have a local maven repository and installed a custom artifact. It works if i reference it in other projects. But now i want to use a server for a "own maven repository". If i delete the artifact from the local maven repository, i assumed that the project will not build when i do a maven clean and maven force update dependencies. The artifact cannot be found under .m2/ but Spring Source Tool Suite still can add the artifact to new Java Projects. Create New Java Project -> Edit Pom -> Maven Artifact is added, even if i deleted it from local repository .m2/ . How is this possible and how can i delete it completely, to be able to test if now all dependencies are updated from my server with the .m2/settings.xml configuration?
Your repository is just a directory/file structure. Go to your local repo, find the path (the group id is the path), and delete from the place where you start to see version numbers. When you rebuild, the artifact should be downloaded/replaced from your server/repo.
Will the .m2 folder be created automatically by Maven, or do you need to create it manually?
What does the .m2/repository, contain and from where does it come?
First, it will be created by Maven when you execute a build, such as:
mvn clean install
Note, you could find this out just be executing mvn your self ;)
Second, the contents of .m2 are:
A settings.xml file that contains global settings for all maven executions.
A folder called repository that holds all of the local copies of various maven artifacts, either caches of artifacts pulled down from remote repositories, such as Maven Central, or artifacts built by your local maven builds. The artifacts are organized in there in folder structures that mirror the groupId's of the artifacts.
It will be created automatically. The repository folder (also called local repository) will download its content from repositories specified in your user's settings.xml, the global settings.xml and possibly in your poms.
Most artifacts will be downloaded from repo1.maven.org.
i am getting this exception when try to run as-> maven build
.m2\repository\commons-logging\commons-logging\1.1\commons-logging-1.1.jar; cannot read zip file entry
I've already spent a day on it , searched over google , but no luck
any idea how can i resolve this
thanks
Try to open the jar with a Zip utility (7Zip ou something else).
If it fails, delete the file from your local repository, and retry to run your app.
If it fails again, then you may have an issue with your Maven repos config.
If maven downloads corrupt jars (jars that do not open with a zip utility) - try downloading those perticular jars manually and replace them in the appropriate repository folder location.
In settings.xml specify the localRepository path explicitly. Using the default settings (i.e. not specifing localRepository) causes maven to download the jars again and again when you do a "clean install" and you end up have the corrupt jars again.
In my experience, it is caused by a corrupted zip file. A failed build often appends to the jar, but doesn't delete it, therefore producing an unreadable file.
The solution, as suggested, is to delete the jar, then try to download again from the repository (create a maven build with package goal) If that repeatedly fails, the remote location might be corrupted.
Delete the m2 repository folder and try running your maven ,it will download all the jar files again and the build success