How to copy files with IntelliJ - maven

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

Related

Setup SpringBoot in IDEA from Initializr

I don't understand what happens (before everything worked, feels like I've lost some settings somehow). I download archive from initializer (spring.io; doesn't matter which dependency include, let's say only Spring Web), extract from archive and open project from IDEA. First of all, I'm receiving file ***.iml outside of the container (before it is automatically was created inside)
Also now I have to Assign to "java" folder MarkDirectoryAs - SourceRoot by hand (before this staff applied authomatcally).
And finally looks like IDEA does not see the itself downloaded dependencies. When the project just opened I receive this:
How can I fix it?
UPD:
Errors after reload
And Libraries do not have Maven...
Also what I've found out, I have an error with link to local repository and do not have link to external (like in previous projects)
don't know how to fix it.
Also in my Maven only Lifecycle folder presented now.
Maven Home Path choose as shown on the pic. (Settings->Build,Execution,Deployment->Build Tools->Maven)

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 IntelliJ IDEA open Gradle's own source code?

I'm working on a Gradle plugin. Sometimes I want to look at the source code or Javadocs of Gradle's own classes. I want to do it from IntelliJ IDEA, without having to open a separate application. That is, Ctrl+click or Ctrl+B on a Gradle method or class and have IntelliJ open the source code of Gradle itself.
I have tried everything from Attaching Gradle sources in IntelliJ IDEA :
adding wrapper { ... } block in build.gradle
file gradle/wrapper/gradle-wrapper.properties has distribution type all (and, to my knowledge, has never had other distribution type on this particular machine)
I have also tried attaching sources manually by downloading Gradle source code from GitHub, but IntelliJ doesn't seem to be able to ingest it.
In addition to that, I have tried standard troubleshooting remedies of IntelliJ:
Refresh Gradle project
File > "Invalidate Caches / Restart" > "Invalidate and Restart"
Yet, when I click on method project.getProperties() (as an example), IntelliJ IDEA opens decompiled Project.class instead of the source code file Project.java.
How to make IntelliJ IDEA open Gradle's own source code?
Looks like you are facing this issue: IDEA-197970.

Spring STS not recognizing project structure with Gradle

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!!!

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