Spring STS not recognizing project structure with Gradle - spring

I'm trying to do this getting started guide from Spring. So I cloned the project using git from the command line. As I'm working with Gradle, I removed the Maven files from the repository to clean the project.
After that I open my STS and go to File -> Open Projects from File System and navigate to the /initial folder of the repository. The project is imported correctly but when I try to add some "java stuff" (packages, classes, etc.) I get several errors and I can only add folders and files, which is quite annoying for working.
To be more descriptive, I'll add some images so you can see what's happening. This is the project initially imported into STS as I described above:
Then I try to add some java stuff, let's say for example a source folder. So Right Click on library -> New -> Source folder and this is the result:
And in the properties of library I have the following:
So the question is: how can I tell to STS to recognize the library folder as a Java Project (or Gradle module, I don't know how to call it) instead of a plain folder so I can add my packages and classes?
Thanks in advance for your answers.

In case you would like to work with Gradle, you should use the Gradle integration for Eclipse (project Buildship) and install that into your STS environment. After that, you should be able to import the projects either from disc as existing Gradle project (not as file system) or via the wizard that integrates the spring guides into STS (Import Getting Started Content). The wizard for the guides also let you choose between the Maven and the Gradle variant, so you don't need to close and delete stuff yourself.
Hope this helps!!!

Related

Modules, Gradle Subprojects, and IntelliJ Woes?

I am trying to make use of modules and gradle subprojects and either receive compile time errors or complaints from IntelliJ.
My project structure is as follows:
Root
- settings.gradle
- core
- build.gradle
- desktop
- build.gradle
- src/main/java/module-info.java
The desktop build.gradle file as a requirement on core as:
dependencies {
implementation project(":core")
}
There is no reference to the "core" project in the module-info.java files.
In this configuration, IntelliJ doesn't like usage of classes from the "core" project in the "desktop" project (I see a lot of red), but running gradlew.bat desktop:run works with no issues. Bug with IntelliJ? I am using microsoft's openjdk, but hopefully that doesn't matter.
My best attempt to fix this, was to add a module-info.java file to the core project as well and reference the core project in the desktop project's module-info.java file. Unfortunately this configuration, while making IntelliJ happy, renders me unable to run the desktop from command line anymore. I get errors about the core project being unable to find required modules that are the exact same as the required modules I pull in for the desktop module. I think this might be an error on my part, but I'm not sure how or what to do to fix it.
Would appreciate any insight.
P.S. Of these issues, I think I would prefer to get IntelliJ working with the first setup, because I intend to have this core library be shared between the desktop project and an android project, and while I haven't looked into it yet, I am not sure Android supports new java modules?
I think terminal should be the first priority. If your original setup made it compiled successfully under terminal, then there is no problem in your project. Do not add extra files for just making the IDE happy.
There's still something you can do. The first step is compiling your project successfully under terminal. This step downloads all the necessary dependencies before IntelliJ, reducing the problem scope to IntelliJ's linking and indexing. Then there are some options:
In the Gradle tool window, click the top-left button Refresh all Gradle projects.
Delete all the .idea folders in your project. Then open the root folder of your project via UI or CLI.
Click the invalidate caches/restart in the main menu.
You can also also create a new Gradle multi-module project with command gradle init, and open it with IntelliJ. It should be analyzed by IntelliJ normally. Then you can compare its project structure with yours. Maybe there's something different.
Hope these steps could help you.

How to make Spring Tool Suite like a multi-maven-module project?

I'm trying to create a Spring Boot project with multiple Maven modules. I've used the tutorial at https://spring.io/guides/gs/multi-module/ .
This site recommends a directory tree like this:
parent
application
src, and other subdirectories
pom.xml
library
src, and other subdirectories
pom.xml
pom.xml
I developed this project using Visual Source Code.
Wanting to see the project in another light, I tried to import the project directories into Spring Tool Suite. I'm using a recent one, where you apply the STS plugin to an up-to-date Eclipse installation.
Well, STS doesn't really like this project.
The (File, Open projects from file system) sees the project, but the Finish button doesn't actually do anything.
The (File, Import, General, Existing Projects into Workspace) imports a project, but as a Maven project (no "J" icon). When I try the (Run, Run Configurations) it won't see my project.
How can such a project be made friendly to Spring Tool Suite?
Thanks,
Jerome.
To make multi maven projects what you can do is, simply download two separate maven projects from start.spring.io and then extract them and move both folders to one parent folder and try grabbing the parent folder to Intellij, so it automatically downloads the dependencies and other requirement for the project in which we have two maven projects in one single entity
Eclipse can be a bit confusing with several different Wizards to import projects. Ironically the wizards are supposed to make importing projects easy, and in a sense they do... but... unfortunately picking the right wizard itself can be a bit challenging / confusing. Which wizard you use depends on the type of project.
Since your projects are maven projects, the best wizard to use would be the one for maven projects. You can find it at "File >> Import >> Existing Maven Projects".
So give that a try, point it at the 'parent' folder of your project and you should be presented with a relatively intuitive UI to import all 3 projects and configure them for use in Eclipse.

IntelliJ No files were downloaded for xyz

I've created a new project in IntelliJ.
When I go in to:
Project Structure -> Libraries -> Add -> From Maven -> 'com.atlassian.seraph:atlassian-seraph:3.0.3'
I get the error message 'No files were downloaded for com.atlassian.seraph:atlassian-seraph:3.0.3'
Backstory:
I'm using IntelliJ to write a custom SSO authenticator for JIRA. This is not a JIRA plugin, it's just a class that a custom JSP will use.
I intend to produce a JAR and put it in WEB-INF/lib.
I'm not sure what I've missed here. This is my first exposure to maven and I've googled this extensively.
If you did not change the default remote repository of your maven, it should be this . It seems that the artifact (com.atlassian.seraph:atlassian-seraph:3.0.3), you are looking for, is not in the default remote repository. There are two solutions for your case,
1.Add a new remote repository, which has this artifact, to your project.
2.Find the jar file somewhere on internet, add it to your project as an external jar file. Here is a great tutorial about this.
I've changed from idea 14 to idea 15, and downloading maven jar feature started to work)
My Maven setup in ide aimed to external v3.2.1, but may be it would work even with bundled one.

How to copy files with IntelliJ

I'm using IntelliJ 14.1.1 on Windows.
I have a project (mainly java) with a little web module, built with maven.
In my web module, I'd like to accomplish this scenario :
I edit a Javascript file located in the web module, folder resources/js
When IntelliJ automatically saves the file, I'd like it to be copied automatically to target/classes so that my web server detects the change and reload it automatically.
My goal is to have immedlate feedback : I edit a JS file, and then I have it available in my browser.
The only way I found is to go to "Maven Project", and assign a shortcut to the maven goal which compiles the module. But this takes too long, and it's far from the "Ctrl+S" of Eclipse (Eclipse auto build let me have this behavior).
I also tried to use the File Watcher option of IntelliJ, but it seems it can only parse less/css and I cannot make a simple copy of file/folder with it.
Any help would be welcome to achieve such an immediate feedback on typing in IntelliJ.
Thank you

Adding existing source packages to a Maven Web Application in Netbeans

I have a normal Netbeans project, and I would like to add the source packages of this project to a project that is a Maven Web Application, also within Netbeans.
I tried copy-pasting the packages into the /src project directory of the Maven application, but this doesn't seem to work.
Could someone please tell me how I could do this ?
If this is not possible, could someone tell me if I can convert the entire normal project into a Maven Web Application ? Thank you :)
It sounds like you need to add the dependency to your web-application instead of the source code, cause maven is intended to handle exactly such situations.

Resources