Eclipse error during resolving gradle dependency - java

I have added the dependency com.sun.mail:javax.mail:1.5.4 to build.gradle, but Eclipse doesn't resolve this dependency and throws this error
Illegal entry in Gradle Dependencies: D:/Programs/Eclipse/unresolved dependency - com.sun.mail javax.mail 1.5.4 PluginName Unknown org.springsource.ide.eclipse.gradle.core.classpathcontainer
I tried to clean & rebuild the project, refresh dependencies many times, but I still get the same error and the dependency doesn't download. What can be wrong?
My build.gradle file:
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'PluginName',
'Implementation-Version': version
}
}
repositories {
mavenCentral()
maven {
name 'Sponge maven repo'
url 'http://repo.spongepowered.org/maven'
}
}
dependencies {
compile 'org.spongepowered:spongeapi:2.1-SNAPSHOT'
compile 'com.sun.mail:javax.mail:1.5.4'
}
test {
systemProperties 'property': 'value'
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}

I definietly don't know why, but It started to work and dependency just downloaded.

Related

Why do I get Gradle configure build error junit5 in IntelliJ?

I created clean project with spring boot initializer and I get configure build error. The message I get is: Could not find org.junit:junit-bom:5.4.0-SNAPSHOT. but in my gradle file I don't have it. What's wrong with it?
buildscript {
ext {
springBootVersion = '2.2.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 11
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-web')
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('org.springframework.security:spring-security-test')
}
You're using a development (snapshot) version of Spring Boot that refers to a development (snapshot) version of JUnit 5, but you have not added JUnit's snapshot repository: https://oss.sonatype.org/content/repositories/snapshots/org/junit/junit-bom/5.4.0-SNAPSHOT/:
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
But you'd better use generally available versions.
The Junit dependency comes with "spring-boot-starter-test", it may not be available in your spring version. Try to change the spring version or use a latest version and give it a go.

Could not find or load main class in Groovy gradle project

I have groovy application that i want to pack in executable jar with gradle.
The problem is when the jar is done i have error: Could not find or load main class .
Here is my build.gradle:
group 'com.demo'
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin:'application'
mainClassName = 'com.demo.App'
buildscript {
repositories {
mavenCentral()
}
dependencies {}
}
repositories {
mavenCentral()
}
// java version dependency
sourceCompatibility = 1.8
targetCompatibility = 1.8
jar {
baseName = 'cim-configurator'
version = '0.1.0'
manifest {
attributes("Build-Time": new Date().format("yyyy-MM-dd HH:mm:ss"),
"Build-Jdk": System.getProperty("java.version"),
"Built-By": System.getProperty("user.name"),
"Created-By": "Gradle",
"Main-Class": "com.demo.App"
)
}
}
Here is the file hierarchy:
com.demo
ActiveMq
App
Database
Rbac
Run.groovy
Service
I think that using uberjar will fix your problem. It worked with similar case for me.
I had this exact same problem in a Groovy & Gradle project. This is the answer that fixed this problem.
TL;DR
Use the Shadow-jar plugin by adding the following plugin to your plugins block in build.gradle:
plugins {
id 'com.github.johnrengelman.shadow' version '5.0.0'
}
Then run ./gradlew shadowJar
You'll get a jar file emailer-all.jar, which can be run.

Could not find android-maven-gradle-plugin.jar while updating android studio 3.0.1 to 3.1

I am facing with following issue while updating android studio 3.0.1 to 3.1
Could not find android-maven-gradle-plugin.jar (com.github.dcendents:android-maven-gradle-plugin:1.5).
Searched in the following locations:
https://jcenter.bintray.com/com/github/dcendents/android-maven-gradle-plugin/1.5/android-maven-gradle-plugin-1.5.jar
Below is my build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.novoda:bintray-release:0.3.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'io.fabric.tools:gradle:1.24.4'
}
}
Please help
Got solution,
error resolved by updating
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
to
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
In gradle-wrapper.properties use this :
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
and update buildToolsVersion to 27.0.3
Gradle Android Maven plugin
To use the android-maven-gradle-plugin, just apply the plugin in your android-library project. Also add the plugin classpath dependency to the buildScript.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
OR use gradle 2.1
plugins {
id "com.github.dcendents.android-maven" version "2.0"
}
You can set the maven groupId and version in the script build.gradle:
group = 'com.example'
version = '1.0'
set in settings.gradle:
rootProject.name = 'artifact'

Execution failed for task ':compileJava'

I am trying to build a Spring cloud application that provides details of a Customer and the order history he/she has made in the past via gradle. When I am executing the build and clean task, I am unable to obtain the target jar file because of this error.
Execution failed for task ':compileJava'.
This is the message shown in the ExceptionStackTrace of the error log.
org.gradle.tooling.BuildException: Could not execute build using Gradle installation 'C:\gradle\gradle-3.4.1'.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
Below is my build.gradle file.
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'yBayApplication'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-turbine:1.2.3.RELEASE')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.cloud:spring-cloud-starter-hystrix-dashboard')
compile('org.springframework.cloud:spring-cloud-starter-hystrix')
compile('org.springframework.cloud:spring-cloud-starter-feign')
compile('org.springframework.cloud:spring-cloud-starter-eureka:1.2.3.RELEASE')
compile('org.springframework.cloud:spring-cloud-starter-ribbon')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.BUILD-SNAPSHOT"
}
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
I have checked the Java version which gradle uses and it points to the right directory C:\Program Files (x86)\Java\jdk1.8.0_121 and I have also included the gradle.properties file in the project to be double sure that it fetches only the Java_home properties
gradle.properties
org.gradle.java.home=C:\Program Files (x86)\Java\jdk1.8.0_121
I had also changed the eclipse.ini file by adding the following lines.
-vm
C:\Program Files (x86)\Java\jdk1.8.0_121\bin\javaw.exe
Still I find that the gradle build is failing.
What am I doing wrong?

Gradle build successful, error running jar

I am new to gradle.
I am building a project using gradle.
It build successfully without any error. While running the build jar file it is giving classNotFoundException.
I am building a simple spring project from spring.io
However question look similar to this but, could not find a solution. Please help.
edit: This is how my build.gradle looks
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
startScripts {
mainClassName = 'Application'
}
springBoot {
mainClass = "Application"
}
You'll need to start the application with the generated start scripts. They will automatically take care of setting up the proper classpath.

Categories