How to download Griffon distribution in Intellij Gradle project? - maven

I am trying to start a Griffon project. The Griffon repository is available from bintray. I created a Gradle project in Intellij and added the maven repository provided into the build.gradle file. But the project structure is not being generated. I need to know how create a Griffon project in Intellij correctly. I am adding the code from the build.gradle file that i edited.
apply plugin: 'java'
sourceCompatibility = 1.5
version = '1.0'
repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/griffon/griffon"
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}

Please follow the instructions found at http://griffon-framework.org/ and http://griffon-framework.org/tutorials/1_getting_started.html.
Note that IntelliJ includes a Griffon plugin that works with Griffon 1.x but does not work with Griffon 2.x. Griffon 2 can be opened/imported as a normal Gradle or Maven project.

Related

Maven Project in IntelliJ, include Gradle Plugin

I'm new to IntelliJ and Gradle
I've got a Maven Project with a lot of dependencies which works on it's own.
Now I should use the libraries from that Project and create a Plugin for IntelliJ in Gradle.
I tried various ways to add the dependencies in the IntelliJ Module Settings, which allowed me to use the needed classes to write my code and build it. However, when I tried to start the plugin, it couldn't find the classes anymore.
I think I need to specify these in the build.gradle but I don't understand exactly how, as all the ways I tried didn't worked.
build.gradle:
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.6.5'
}
group 'com.ast.devmate.intellij'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
**compile 'com.ast.devmate.intellij:root:1.0.0-SNAPSHOT'**
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version '2019.1'
}
patchPluginXml {
changeNotes """
Add change notes here.<br>
<em>most HTML tags may be used</em>"""
}
gets me this:
Could not find com.ast.devmate.intellij:root:1.0.0-SNAPSHOT.
without the line marked with ** I got a lot of
error: package foo does not exist
import foo;
It looks like you're trying to access a custom library using Gradle. You will probably need to use a file dependency: How to add local .jar file dependency to build.gradle file?

Adding sources for IntelliJ plugin via Gradle

I've setup an IntelliJ plugin using Gradle. My build.gradle file contains:
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.12'
}
//...
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
intellij {
version '2018.2.4'
plugins 'git4idea'
}
Is there any way how I can include/download the sources of the Git4Idea plugin to the project so that they are available automatically?
No, you can't. It'a bug. I filed it here on the plugin's issue tracker.

compile find a bad version of gradle

I use spring boot 2. In a multi java project.
I try to build my main library (no yet java file)
apply plugin: 'java-library-distribution'
plugins {
id 'org.springframework.boot' version '2.0.0.M7'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.0.M7'
compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.0.0.M7'
}
distributions {
main{
baseName = 'common-model'
}
}
sourceCompatibility = 1.8
tasks.withType(JavaCompile) {
options.compilerArgs = ["-Xlint:unchecked", "-Xlint:deprecation", "-parameters"]
}
In my gradle/wrapper, i have
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip
error i get
caused by: org.gradle.api.internal.plugins.PluginApplicationException:
Failed to apply plugin [id 'org.springframework.boot']
Caused by: org.gradle.api.GradleException: Spring Boot plugin requires
Gradle 4.0 or later. The current version is Gradle 2.13
i don't find any 2.13 version
In my main project i have
buildscript {
ext {
springBootVersion = '2.0.0.M7'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
mainClassName = 'com.zirgon.EmailApplication'
group = 'com.zirgon'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
tasks.withType(JavaCompile) {
options.compilerArgs = ["-Xlint:unchecked", "-Xlint:deprecation", "-parameters"]
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile project(':common-model')
compile('org.springframework.boot:spring-boot-starter-mail')
compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
It's possible you might be building the project with gradle installed locally instead of using the wrapper i.e. using gradle build instead of ./gradlew build.
These are the steps I took to fix the same problem.
I had a new project with a build.gradle file, but did not have a copy of gradle wrapper in my project directory. I think this caused the default gradle version for my IDE to be used (IntelliJ) and this is an older version.
Gradle was already installed on my system.
Ran "gradle wrapper" in my project directory.
Edited ./gradle/wrapper/gradle-wrapper.properties and made sure "distributionUrl" was pointed at the gradle version I wanted (4.6 in my case).
Reran my build and the correct version was then downloaded and installed. Problem fixed.
I hope this helps someone!
I copied my gradle wrapper folder over from another project, and edited ./gradle/wrapper/gradle-wrapper.properties
I'm running Eclipse 2018-2019/STS 4.0/Buildship Gradle 3.0. I solved the problem by configuring Eclipse > Gradle > Properties.
Specifically:
Eclipse > Gradle > Update Gradle Project >
Error: Spring Boot plugin requires Gradle 4.0 or later. The current version is Gradle 3.4.1
Everything looked OK in Eclipse > Window > Installed Software So I checked my Windows user profile directory:
Directory of C:\Users\paulsm\.gradle\wrapper\dists
06/11/2017 09:14 AM <DIR> gradle-3.3-all
12/07/2018 06:23 PM <DIR> gradle-3.4.1-bin <-- Eclipse using this version
11/01/2018 02:38 PM <DIR> gradle-4.1-all
11/01/2018 02:50 PM <DIR> gradle-4.4-all
12/07/2018 03:02 PM <DIR> gradle-4.8.1-bin
Eclipse > Window > Preferences > Gradle > Gradle distribution > Changed from "Gradle wrapper" => "Specific version: 4.8.1"
Re-ran Eclipse > Gradle > Update Gradle Project => SUCCESSFUL
This effectively ignores the project's local gradle wrapper settings, and ensures that I'll have the "correct* settings for ALL my Eclipse projects going forward.
I can always re-configure Gradle on a per-project basis (reverting back to 3.4.1 or older) if I ever need to.
Another option is to change the Gradle wrapper properties.
Error message:
> Failed to apply plugin [id 'org.springframework.boot']
> Spring Boot plugin requires Gradle 4.4 or later. The current version is Gradle 4.0
Change the distributionUrl value in gradle-wrapper.properties (located in /gradle/wrapper/) from:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-bin.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
Open gradle/wrapper/gradle-wrapper.properties and change distributionUrl property to 4.6 version or newer one.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip

Gradle dependency management using pom.xml

In build.gradle we specify the dependencies as
compile group: 'org.apache.pig', name: 'pigunit', version: '0.11.0-cdh4.5.0', transitive: true
Running gradle cleanEclipse eclipse sets up the projects(adds the jar to classpath)
However there are only maven dependencies available for some APIs
(I am trying to run jersey 2.x examples bundle from https://jersey.java.net/download.html and it provides only pom.xml)
EDIT:
I know i can specify
compile group: 'groupId', name: 'artifactId', version: 'version' gradle but doing it manually for all dependencies or writing a program to do so should not be natural gradle way.
Gradle provides a maven plugin http://gradle.org/docs/current/userguide/maven_plugin.html.I haven't tried it out but it should be able to do it
Gradle supports Maven dependencies. Just specify the dependencies in the same way as your example:
compile group: 'groupId', name: 'artifactId', version: 'version'
To lookup the the artifact coordinates, you can use sites like http://search.maven.org
The only thing you have to make sure is to include either your internal Maven repository (if you are in a company which has one) or Maven Central:
repositories {
mavenCentral()
}
or
repositories {
maven {
url "http://repo.mycompany.com/maven2"
}
}

Convert pom file to gradle

I am trying to convert a maven build to gradle. I used gradle init to generate the build.gradle file. But, plugins are not resolved properly. Is there any additional setting to be set?
pom file,
https://github.com/bkielczewski/example-spring-mvc-initializer/blob/master/pom.xml
generated file
apply plugin: 'java'
apply plugin: 'maven'
group = 'eu.kielczewski.example.spring'
version = '1.0-SNAPSHOT'
description = """Spring MVC Initializer Example"""
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
compile group: 'org.springframework', name: 'spring-webmvc', version:'4.0.2.RELEASE'
compile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.0.1'
}
Mainly I want to migrate maven-war-plugin configurations to gradle.
gradle init gives a good head start, but can only do so much. Whatever is left needs to be done manually.
Gradle guide clearly explains the usage of "War plugin". Link is http://www.gradle.org/docs/current/userguide/userguide_single.html#war_plugin
In case you want to know all the configurations properties supported by this "war plugin" then refer to
http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.bundling.War.html
However, As per your pom I think you are more interested in knowing how to set the "failOnMissingWebXml" configuration when you saying that "Mainly I want to migrate maven-war-plugin configurations to gradle." There is no property with the exact name in gradle but you can do this with "webXml" property in gradle war plugin as its definition says "The web.xml file to include in the WAR archive. When null, no web.xml file is included in the WAR.".
HTH...

Resources