I have a simple Gradle project.
I have the following in my build.gradle:
compile('javax.inject:javax.inject:1')
And I can see the jar in gradle cache. But in both Eclipse and IDEA I get following message
Error:(8, 20) java: package javax.inject does not exist
The really odd thing is that :build is successful, but there is an IDE message and an error when trying to "run".
I tried creating a Maven project and there I can import "#Inject" just fine.
Related
It showing error like this (Plug-in "org.eclipse.m2e.editor" was unable to instantiate class "org.eclipse.m2e.editor.pom.MavenPomEditor"). when selected POM.XML on maven project
I have try to run the maven project but not able to run it and that was happen only on maven java project not an java project. I want to run the maven project without any error so can you help me out on it.
I get a company's project from Github, and import into the GGTS as a gradle project. Everything runs OK. gradle task show this.
I want to create a new Grails app, so I used the command grails create-app wtf, and then import into GGTS as a Gradle project. What make me confused is that the file named build.gradle or the folder named .gradle do not appear, gradle task shows null like this, while I do the same thing in system of company and it runs fine.
Please tell me what happend? And I did not write a build.gradle in system of company manually.
The problem is Grails 2.4.4 does not use Gradle. That didn't start until Grails 3.0.
I believe you need to import the project as a Grails project (I haven't used ggts in a long time, so my recollection it's foggy). You can read more about IDE integration here.
I'm converting an existing Maven based project containing a Grails 2.4.2 application to Gradle 2.6 and Grails 3.0.4. It's a mixed environment with Java, Groovy, and Grails used in several sub-projects. I've converted all the pom.xml files into build.gradle files, starting off with ./gradlew init, and then hand editing as needed. Before converting the Grails project's grails-app/conf/BuildConfig.groovy to the build.gradle equivalent, everything built fine with Gradle 2.6. After I converted the Grails project's BuildConfig.groovy file to build.gradle, I'm getting the following error when trying to run ./gradlew build:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':foo:runtime'.
> Could not find json-lib-jdk15.jar (net.sf.json-lib:json-lib:2.4).
Searched in the following locations:
file:/Users/xyz/.m2/repository/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
The json-lib-2.4.jar file does exist in the local M2 cache shown above, but it doesn't have the -jdk15 part in it. There's no explicit dependency to any json-lib jar file in the build.gradle file for the Grails project. A parallel project does have an explicit dependency on this library, but that project builds fine. I've tried to explicitly add the dependency to the build.gradle file in the Grails project both with and without "classifier: 'jdk15'" to the dependency declaration. When I ran ./gradlew dependencies, I noticed that an older version (2.3) of the json-lib jar file showed up in the list as an implied dependency for some Apache HttpComponent stuff. I then tried both versions of this in the allProjects section of the top level build.gradle:
configurations {
all*.exclude module: 'json-lib'
}
as well as:
configurations {
all*.exclude module: 'json-lib', classifier: 'jdk15'
}
Neither variant makes any difference. I'm really stuck on this and would appreciate any tips on how to move forward. In case it makes a difference, I'm running this on a Mac with MacOS 10.10.5, the JDK version is 1.8.0_25-b17. Thanks.
dependencies {
//compile group: 'net.sf.json-lib', name: 'json-lib', version: '2.4'
compile "net.sf.json-lib:json-lib:2.4:jdk15"
}
I upgraded to IDEA 14 (from 13) and when I attempt to run my grails 2.2.0 application, I am getting the following error:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/gdboling/Projects/GenRocket/web/build.gradle' line: 92
* What went wrong:
A problem occurred evaluating root project 'web'.
> No such property: environment for class: org.gradle.api.internal.project.DefaultProject_Decorated
It would seem that IDEA is attempting to use my build.gradle as part of the grails build process. IDEA 13 didn't do this. I use the build.gradle for some other non-grails related tasks for the project.
If I remove the build.gradle file all together, I get this error:
FAILURE: Build failed with an exception.
* What went wrong:
Task 'grails-run-app' not found in root project 'web'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I do see the Grails View in the IDE but when I try and do a Make, it is telling me to re-import the gradle project. So it would seem that IntelliJ think this is a gradle project. How I can tell it that is is just a grails project?
To confirm my suspicions, I've opened a grails project that did not contain a build.gradle and it works just fine.
I had faced similar issue when unknowingly kept on hit next next in hurry. So, you probably mistakenly created a gradle project as shown in screenshot.
And when you recreated the project created it as "Create project from existing source" which idea well knows as grails-app (default for idea).
See if you can reproduce the error by re-importing the project using import project form external module.
Complete gradle nooby here.
I want to be able to execute grails build commands like "grails compile", "grails test-app" and so forth from gradle.
I found the grails-gradle-plugin from Peter Ledbrook at: https://github.com/grails/grails-gradle-plugin.
Cloning the repository I get some files and folders. In the readme file it says " include the required JARs via buildscript {} and 'apply' the plugin". The apply part sure I get but how do I add the JAR? And which jar? Do I need to use gradle on the build file in the folder of the downloaded plug-in and compile a jar? And ones I get the jar where do I place it and how do I include it in my projects build.gradle file?
I have a feeling this is going to be ridiculously easy but I just can't get it to work.
In Gradle, the jars are added to build script or to your application class path through dependencies closure e.g.
dependencies {
compile "org.grails:grails-crud:1.3.4"
compile "org.grails:grails-gorm:1.3.4"
compile "ch.qos.logback:logback-core:1.0.7"
compile "org.slf4j:slf4j-api:1.7.2"
}
compile is a name of one of the many configurations (there are also test, runtime etc.) and e.g. "org.grails:grails-crud:1.3.4" is a reference to a jar in one of the public repositories, which are also specified in your scripts in repositories closure.
You can read more about Gradle dependency management in http://gradle.org/docs/current/userguide/dependency_management.html.
For your Grails project you need to define a build.gradle file which looks similar to what is described in the README.
Though I tried today to just create a simple Grails project using that plugin and gradle init command and it didn't work. I have created an issue for that: https://github.com/grails/grails-gradle-plugin/issues/16.