I have a scala/sbt project, and there is a build.gradle file from when I was experimenting one time. Intellij saw the build.gradle and has enabled gradle for the project. Can I turn off gradle for the project?
I have deleted my build.gradle and any gradle directories in my project but I keep getting messsages like the below, so I'm guessing there is a setting in intellij I need to turn off.
7:31 pm The IDE modules below were removed by the Gradle import:
knot-alpha
You can open dialog to select the ones you need to restore.
Close the project
Remove all Gradle related files and directories:
build.gradle
settings.gradle
gradle.properties
gradle/
Delete the hidden .idea/ directory
Reimport project
In addition to Fracisco Mateos answer:
It should be enough to remove the gradle.xml from the hidden .idea directory. This will remove the Gradle "nature" of the project in IntelliJ without having to delete all your workspace metadata.
Removing the build.gradle, settings.gradle, gradle.properties and gradle directory probably isn't necessary, but, of course, makes sense in order to have a clean project.
Related
I have installed gradle with chocolatey package manager, but in .gradle directory there is no gradle.properties file. Do I need to re-install gradle? or what should I write besides what I need to add in grdle.properties file If I will create it?
P.S: I use gradle plugin in Spring Tool Suite, and I need to add something in the gradle.properties file concerning the project
The propery file gradle.properties is not created automatically during Gradle installation. You can create this file manually and add your specific configuration into it. Note that there are two places where you can create a gradle.properties file, as described in documentation Gradle configuration properties
I've rolled onto a maven project that when I run mvn clean install from command line builds and runs fine. I had this project displaying in Eclipse without errors earlier in the week before I hosed my system. This makes me think I have a configuration wrong and hoping someone can give me a sanity check.
Inside of Eclipse, I'm seeing reported errors related to org.springframework cannot be resolved to a type in files in paths like <project_path>/target/<project>-<version>/WEB-INF/... What is catching my eye is that path of target which is a derived folder.
Maven Dependencies Showing:
Facets Enabled:
Project Explorer View:
From the above screenshots, you can see that the related jar files are pulled properly from the maven dependencies. Any ideas on what I have misconfigured and why I'm seeing the errors from the target path?
The build and WebContent folders indicate that you haven't properly imported Maven project into the Eclipse, hence errors.
One of the way to fix this:
Delete project from the Eclipse.
Go to project folder and delete all not needed folders. (Leave src).
Go to Eclipse click File -> Import..., select Existing Maven Projects, select your project folder, Finish.
In a normal project, I can have a structure like this:
myProject/
build.gradle
gradle.properties
**settings.gradle**
but if I have another project
myProject2/
build.gradle
gradle.properties
it works fine.
Things go strange when myProject2 is a subfolder (but not sub-project) of myProject.
myProject/
myProject2/
build.gradle
gradle.properties
build.gradle
gradle.properties
settings.gradle
How does gradle find what settings file to use?
The settings.gradle file has the next 2 main purposes:
Add libraries to your build script classpath
Define which projects are taking part in the multi-project build
Therefore it is optional for a single-project build but due to #2 it is mandatory for multi-project builds.
By default it is assumed that the location of the settings file is also the location of the root project but you can redefine the location of the root project in the settings file.
Now, gradle logic for locating settings.gradle file as documented in gradle user guide here:
If you trigger a multiproject build from a directory with a settings
file, things are easy [Amnon - you just found it]...
If you execute Gradle from within a project with no settings.gradle file, Gradle looks for a settings.gradle file in the following way:
It looks in a directory called master which has the same nesting level
as the current dir.
If not found yet, it searches parent directories.
If not found yet, the build is executed as a single project build. If
a settings.gradle file is found, Gradle checks if the current project
is part of the multiproject hierarchy defined in the found
settings.gradle file.
If not, the build is executed as a single
project build. Otherwise a multiproject build is executed. Otherwise
(you executed Gradle from
(Gradle user guide also provides the purpose of this behavior here).
Now, back to your case, the first two project layouts you provided are for a single project build so settings.gradle is optional. For your third project layout if you'll run gradle from the root project (myProject) then it will find settings.gradle next to it but if you'll run it from myProject2 folder then since this project parent path contains a settings.gradle file, gradle will find it and use it.
I know I should be working with my build.gradle and init.gradle files but I don't know what to write or how to point to my project folder with the pom.xml file.
The first step is to run gradle init in the directory containing the (master) POM. This will convert the Maven build to a Gradle build, generating a settings.gradle file and one or more build.gradle files. For simpler Maven builds, this is all you need to do. For more complex Maven builds, it may be necessary to manually add functionality on the Gradle side that couldn't be converted automatically.
https://guides.gradle.org/migrating-from-maven/
as Peter Niederwieser said:
For more complex Maven builds, it may be necessary to manually add
functionality on the Gradle side that couldn't be converted
automatically.
although you have to write some parts manually by your self. there is an online service that may be an useful tool For complex Maven builds. maven2gradle is a project on github which can convert online dependencies element automatically from maven to gradle scripts.
for using it,
get to maven2gradle . URL
open and select contains of your maven file.
Paste your maven dependencies on the text box in that web page (with
or without the dependencies root element).
click Convert button.
for more information http://sagioto.github.io/maven2gradle/
Hi) when I compile the project are with gradle idea, I should get jar file...?
maybe in the folder dist...
The problem is that I get only two files start.sh and start.cmd
gradle idea doesn't compile the project. It creates project files (*.iws, *.ipr, *l.iml) for IDEA (the IDE from JetBrains). Likewise, there is gradle eclipse to create project files for the Eclipse IDE.
To create a Jar, you can do gradle jar or gradle build (assuming you have the java plugin applied). gradle tasks shows which tasks are available for a given project.
start.sh and start.cmd sound like they are coming from the application plugin. Are you using the application plugin?
The above poster is right that gradle idea simply creates the IntelliJ files that define your modules, src locations, etc. It does NOT compile the project.
Adding apply plugin: 'java' to your build.gradle will allow you to run gradle jar to generate a jar file.