IntelliJ IDEA: installing dependencies without build tools? - maven

How can you set up dependencies (the jar files that we usually grab from maven repository) in intellij, without using a build automation tool? Do u download them and install them in you're desktop and somehow connect them to the project you're working on in intellij or you're IDE of choice?

IntelliJ IDEA has a feature that allows to add a library from Maven into the project that is not using Maven. It will download the jars for you. You can also download the files manually and add them to the module dependencies from the disk.

Related

creating spring boot project without maven

I am working recently with spring boot framework
my problem is that I need to set up to environment in a device that has no internet
I have searched A lot but all I found is using maven that will handle the processes of downloading all the dependencies
put I need to add the required dependencies like the old way when you download the jar files and add them to the class-path
is there a way to do so with STS
or is there a way to change where the maven download the dependencies to be from local instead of internet
Never used STS but I assume it uses maven/gradle under the hood.
You can set up local repository and point maven/gradle to it. For example you could use Nexus:
https://www.sonatype.com/products/repository-oss
Another way is to pull dependencies (they get downloaded when you do maven or gradle build and are saved under ~/.m2 or ~/.gradle directories), then copy your ~/.gradle or ~/.m2 directory to the PC with no internet and build offline. With gradle it looks like this.
./gradlew build --offline

Having Maven Plugins in IntelliJ IDEA without Maven Installation in Computer

I just started to use Maven and IntelliJ IDEA.
I imported a project into IntelliJ IDEA which requires Maven. I didn't install Maven to my computer but I have 2 plugins in IntelliJ IDEA named as "Maven" and "Maven Extension". And the code I have is running without any dependency problem.
In that case, do I still need to install Maven from the web or just the plugins in the IntellJ are enough for projects with Maven?
Can we say that for every project? If someone can explain the logic behind I would be very happy.
Thanks a lot!
Intellij comes with a bundled version of Maven (see File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven; the property 'Maven home directory' on that screen by defaults points to 'Bundled (Maven 3)').
You don't have to, but you can still install your own version of Maven, and point that property to it. It has the advantage of being able to run maven from the command-line, which is a better guarantee of build-stability (i.e. building the same project in different environments with the same result) than building directly inside of your IDE. And often is way more helpful in investigating build problems.

Cannot every time use internet for downloading spring-boot-starter-parent-2.3.3.RELEASE.pom from central

Is there any mechanism that if i keep all the pom dependencies locally at some path that everytime it gets picked from that path when i run Spring Boot app from command line?
Example: Everytime i dont't want to donwload the pom dependencies from repository as below and want to keep somewhere locally for use.
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.3.3.RELEASE/spring-boot-starter-parent-2.3.3.RELEASE.pom
I feel your question is a bit strange because it describes the main feature of maven.
When building a project with maven, all the dependencies required by your project are downloaded into a local repository. Future builds won't download again those dependencies.
When running a springboot application using maven, the downloaded dependencies are provided to the application's classpath so they aren't downloaded again.
When running a packaged springboot application, the dependencies are already inserted in the springboot fat jar so they aren't downloaded again.
Another point, if you want to ensure maven does not download anything you can execute maven in "offline mode" using the following parameter "-o"

run maven project with eclipse

I'm new to maven and eclipse. I added m2e-plugin in eclipse and I imported an example of a maven project that I've found in the net.
My problem is when I try to run the project in eclipse using the Run as item menu, I don't find the maven package menu as I learned in the different tutorials.
Is it a problem of installation?
Ok, lets go through this step by step to make sure you have everything you need to get going.
First of all make sure that you have Maven installed (and lets assume you have Java already). You can download it from http://maven.apache.org/download.cgi and installation instructions for Fedora (which I assume is what you are using from your tag) are further down the page.
To test that Maven is correctly installed and working type mvn --help in to the terminal. Eclipse and m2e pretty much just hop on to the terminal for everything Maven related so make sure this is working before proceeding.
Next download an appropriate version of Eclipse. For the sake of this example I've downloaded the Kepler version of the Java EE IDE. In this version of Eclipse m2e comes bundled and to check this you can go to Help > About Eclipse > Installation Details and on the plug-ins tab you should see the m2e connectors.
Now you can import your Maven project in to Eclipse. To do this go to File > Import and then choose Existing Maven Projects under the Maven section. Choose the directory with the example project that you've downloaded and then Finish.
Now, ensure that you have some file inside your example Maven project opened and when you go to Run As... you should now be able to see the maven options. Go to Run As > Maven build... and all you need to do is place the word package in the Goals field and you're ready to roll.
Convert your project to a maven project if you haven't done yet by right clicking on your project in the Eclipse Project/Package explorer. Then follow:
Configure -> Convert to Maven Project
After that you can just right click again on the project Run as and you will see all Maven possibilities to execute your project build/install/clean etc.

IntelliJ IDEA does not create artifacts from pom.xml

I use the IntelliJ IDEA 12.1.4 under Windows and Linux (Ubuntu). The Maven plugin is installed.
I have a big maven project with many poms. Under Windows the IDEA creates artifacts automatically when I do reimport from maven. But under my Linux system the list of artifacts is empty always.
Is it a bug? How to generate artifacts in the Linux case?
Go to the Maven-Projects-View and click "package" for your aggregator project. IntelliJ will then run Maven which creates all artifacts in the target folder. If you run "install", these artifacts will be copied to the local repository. Maybe you didn't do that under Linux yet, so your repository is empty - under Windows, I suppose that IntelliJ was smart enough to refer to those artifacts while importing the project. I personally do not know of any feature in IntelliJ that would automatically package/install all projects on reimport - I'd consider this rather annyoing.

Resources