IntelliJ Add Framework Support missing Maven Option - java

I am trying to add a POM.XML file as per this documentation: https://www.jetbrains.com/help/idea/convert-a-regular-project-into-a-maven-project.html
It says I need to choose 'Maven' from 'Add Framework Support'. But I do not have that option. Why is this so, and how can I enable this option?
Also, I did see this previously in another project I opened in the same IntelliJ IDE on my computer. Does this mean it shows up based on my project contents?
I already have tried installing following maven plugins:
Maven
Maven Helper
MavenPlugin
Maven 2 Integration
Maven Archetypes
Thank you!

Related

Maven connection to IDE

I am using Maven to use Postrgres SQL driver. Besides I am using InteliJ IDEA Ultimatre Edition, and, as I understood, Maven is included in Ultimate version initially. Correct me - all I need, is to set dependencies, and connect PostrgeSQL to Java. I am not oblige to Download Maven (except required Dependecie of course, I mean Maven as framework)? Thanks a lot!
When you are creating a new project, choose Maven. After the project is created, you will receive an empty Maven project structure with the pom.xml and a script mvnw of Maven Wrapper, which you can use (instead of mvn) to build your app.
Just add dependencies to the pom.xml and build.
The Maven Wrapper will do the work for you - download Maven into the project subdirectory and use it.

Gradle Plugin dependency

What is the exact dependency I need to develop a Gradle Plugin in Java? Ideally I would like to get it from a well-known repository such as Maven Central or similar.
I have a Maven project with a core functionality and I just added two extra plugins, one for Ant, one for Maven. They are already tested and working; easy! Now, I wanted to add a third module for a Gradle plugin to make this functionality also available from any Gradle project.
However, I can't find the exact dependencies I need to develop a Gradle plugin.
The Gradle docs (such as https://docs.gradle.org/current/userguide/java_gradle_plugin.html) are not very well written to say the least. They mention:
the gradleAPI() dependency
or the java-gradle-plugin dependency
But they are quite unclear... no group, no version (really?).
If anyone can enlighten me to where I can get these dependencies from, I would be very thankful.
Gradle's public and internal APIs, aka gradleApi(), are bundled with the Gradle distribution and not independently published and therefore not easily consumable by Maven builds. There's the pending epic #1156 (Ensure plugin cross-version compatibility by allowing a user to depend on gradlePublicApi()) that might help here.
Since Gradle plugins are best to be built with Gradle, a pragmatic solution is to invoke the Gradle build from Maven and attach the produced artifact to the Maven build. Andres Almiray (aalmiray) once described this in the blog post Running Gradle Inside Maven (Web Archive Link). He describes the following high level steps:
Create a new Maven module (e.g. gradle-plugin) and add attach it to the parent POM
In the POM of gradle-plugin add a dependency to your core module. Use the maven-dependency-plugin to store dependencies to the Maven build folder, e.g. target/dependencies.
Create the build.gradle, add a Maven repository that points to target/dependencies (step 2) and let it depend on the core module as well as gradleApi(). Implement the Gradle plugin.
Use the exec-maven-plugin to invoke the Gradle build.
Use the maven-resources-plugin to copy the Gradle built plugin jars to the standard Maven build folder.
Use the build-helper-maven-plugin to attach the copied jars to the Maven build.
Sample project to be found here (gradle-in-maven).
https://docs.gradle.org/current/userguide/custom_plugins.html#sec:custom_plugins_standalone_project
In here it is mentioned that it is gradleApi() and I know that this works (from experience). The localGroovy() on that page is only needed if your plugin code uses groovy (does not apply if you only use groovy in the build.gradle of your plugin).
java-gradle-plugin is a library that makes it a bit simpler to make plugins, it is not required though. I personally prefer using gradleApi only.
EDIT:
It appears I've misunderstood the question. Here are the steps to get gradleApi jar:
Create a Gradle project with your desired Gradle version.
Add implementation gradleApi() dependency.
Import/run the project once.
Go to your .gradle folder (located in home folder in Linux-based operating systems).
Open caches folder
Open the version folder you want, e.g. 6.0.1
Open generated-gradle-jars folder.
Copy the jar to wherever you want and use it.
For me the 6.0.1 jar is at ~/.gradle/caches/6.0.1/generated-gradle-jars/gradle-api-6.0.1.jar
Please note that I have not tested this, I know the jar is there but I haven't tried using it.

when installing ireport plugin it shows message as "Some plugins require plugin org.jdesktop.layout to be installed"

I am developing a java project that generate a sales report. I am willing to create the report with jasper report and when I installing the plugins it shows an error as "Some plugins require plugin org.jdesktop.layout to be installed"
How can I solve this?
You have to install org.jdesktop.layout plugin too, download link http://137.254.56.27/nexus/content/groups/netbeans/org/netbeans/api/org-jdesktop-layout/RELEASE65/
You have to install org.jdesktop.layout plugin from the below link
http://137.254.56.27/nexus/content/groups/netbeans/org/netbeans/api/org-jdesktop-layout/RELEASE65/
If you find the above link broken, you can download org.jdesktop.layout plugin or jar or pom from the below link
http://netbeans.apidesign.org/nexus/content/groups/netbeans/org/netbeans/api/org-jdesktop-layout/RELEASE65/
This works for me
Visit the link and download (org-jdesktop-layout-RELEASE65.nbm) by clicking one time on it
http://netbeans.apidesign.org/nexus/content/groups/netbeans/org/netbeans/api/org-jdesktop-layout/RELEASE65/
Then Go to Tools | Plugins...
Select the Downloaded tab...
Press Add Plugins…
Select the plugin file.(org-jdesktop-layout-RELEASE65.nbm)...
Install it and finally problem solved....
It worked with me :=)
The easiest way to resolve dependency issues is to use dependency management software like Maven. This allows for nested dependencies (like this one) to automatically be brought into the project.

What correct maven dependencies to specify for JBehave tutorial project?

I want to study the java spring portion of the Jbehave-tutorial project at https://github.com/jbehave/jbehave-tutorial.
The README.MD states the REQUIREMENTS for building at the bottom:
Building the tutorial has been tested with Maven 3.0.5-3.2.1 and JDK 1.6-1.7. Newer versions of Maven and JDK should work but could also present issues.If you find any, please report them via JIRA
On my computer My Computer I am running Maven Version: 3.3.3 and STS Version: 3.6.4 for 64-bit Windows 7.
I really don't want to make an Atlassian account in order to resolve this issue if I can resolve it on StackOverflow.
So these are the steps I took to build JBehave-tutorial on my machine:
git clone https://github.com/jbehave/jbehave-tutorial.git
mvn clean install -Pstable # Issued in the main parent folder 'jbehave-tutorial'
Imported into Spring Tool Suite (STS) as an existing maven project.
Received the following errors in STS:
This lead me to believe that maven did not correctly download and build those dependencies so I looked into the .m2\repository\org\jbehave folder and this is what I seen.
Did anybody else get this to work?
What workarounds are there?
What correct maven dependencies to specify for JBehave tutorial project in pom.xml(s)?
I'm not immediately clear on your specific situation but here are dependencies required to use JBehave without Spring. (example pom below - you'll only need gherkin if your user scenarios are in gherkin).
https://stackoverflow.com/questions/30685909/jbehave-dependencies-not-available-in-central-maven-repo
I'm also going to hazard a guess that you're going to need the below at the appropriate version.
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-spring</artifactId>
<version>4.0.3</version>
</dependency>
Maven cannot find "SNAPSHOT" dependencies.
You need to google "Maven + dependency name without specified version" and check what is the latest version of them and make appropriate changes in pom file.
For example I have jbehave-web-runner version 3.6-beta-2 NOT 3.6-SNAPSHOT.

In Eclipse m2e, how to reference workspace project?

How can I reference another workspace project using Eclipse m2e?
Do I have to add a project dependency in the project setting? But in that case the dependency is not shown in the pom.
If I set them in the pom, it will not reference the project in workspace but reference the jar in the local repository. Quite annoying, anyone can help?
The correct way to do this is the following:
Use the dependencies section in the POM file exclusively, don't fiddle with the Eclipse project references. Right-click the project, then select Maven > Update Project Configuration to reset the project to the Maven default settings. This way, m2e has ownership of the dependencies.
Make sure all referenced projects are open in Eclipse and have the Maven nature enabled.
Check the Maven settings for each project, make sure that groupId, artifactId and version match with the projects you have open in Eclipse. So if the project you depend on has version 1.0.0-SNAPSHOT in Eclipse, make sure that the depending project's POM file references version 1.0.0-SNAPSHOT in the dependencies section.
Enable Workspace Resolution for each of the projects. Right-click the project, then Maven > Enable Workspace Resolution.
Finally, if the projects are still not resolved, right-click the project again, then Maven > Update Project
This should solve your problem. If after this, your dependencies are still referenced from the file system, check the groupId, artifactId and especially version of each dependency again.
Also check if you don't have any errors in your project - try to run Maven install.
I'd go even further than this.
If you've ever run mvn eclipse:eclipse on your project then you're probably in trouble. I had a situation where I had both a "Referenced Libraries" section and a "Maven Dependencies" section in my eclipse project, with conflicting library versions, causing eclipse and myself inevitable confusion.
The safest thing I found was to run mvn eclipse:clean from the command line then go back in to eclipse, refresh the project, "OK" the resulting problem dialog, and then go Maven > Update Project. This sorted it all out for me.
When eclipse is messed up with importing and deleting several projects, you may need to rebuild index of maven repositories. Here is a way that I have done.
Check if an referenced project is recognized as a maven project by eclipse properly.
In menu bar, click Window -> Show View -> Other...
When 'Show View' window pops up, select Maven -> Maven Repositories
In Maven Repositories window, You should see your project as jar file in Local Repositories -> Workspace Projects
If you can not find your project in Workspace Projects, right click on Workspace Projects and select Rebuild Index.
Update maven of an referencing project
Right click on the referencing project, Maven -> Update Project... -> OK
You also need to make sure that you are running the correct goals.
If you don't run the install goal then it won't be copied to your repository and won't compile.
To learn more about goals have a look at https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
With kudos to #nwinkler's response, the main problem is matching the version number.
A common scenario is that if you are developing a set of projects that are version lock-steped with each other - for example, a project and a set of library projects that are not very loosely coupled, such that a library API might change in a version to be consumed by the relevant app project version, but may change in a way that is incompatible with a past or future version of the app project.
The correct way to set Maven dependencies in such a configuration (and it is also the recommended practice) is to have the app consume specific versions of the libraries - so, for example, if you rebuild an old version of the app, it will use the library version that it previously compiled with.
With the app project's POM library dependency set to a release version (lets say 1.0.0), and while working on the next release with both the app and library projects set to a SNAPSHOT release (lets say 2.0.0-SNAPSHOT), the m2e will not resolve the library version correctly, and will likely download an old version, so that trying to use Eclipse features like "Open Decleration" will target the download jar (sometimes without even a source attachment) which can be pretty annoying.
One way to work around that is to set the app POM dependency version to a range, so instead of depending on 1.0.0, you'd depend on [1.0.0-). With an open range like that, m2e will happily find your workspace library project. But you'd want to set it back to the "correct" version before committing, building and publishing - and this can be very error prone.
My solution is to use build profiles and set a custom profile for m2e, like this:
Set your dependency version with a property, to the version you want to publish against:
...
<properties>
<my.library.version>1.0.0</my.library.version>
</properties>
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>my.library</artifactId>
<version>${my.library.version}</version>
</dependency>
</dependencies>
...
Then add a profile section with an active by default profile that does nothing, and an Eclipse-specific profile that overrides the library version property with a range:
...
<profiles>
<profile>
<id>default</id>
<activation><activeByDefault></activeByDefault></activation>
</profile>
<profile>
<id>eclipse</id>
<properties>
<my.library.version>[1,)</my.library.version>
</properties>
</profile>
</profiles>
...
Finally go to your project properties, and under "Maven" type "eclipse" into "Active Maven Profiles":
Then "Apply and close".
Eclipse m2e will then always see the version range and will resolve dependencies from the eclipse project (even if you have the library installed in the local Maven repo, as the Eclipse project will have a higher version number), but other builders will see the original, strict, version number.

Categories