Gradle ignores internal nexus repository - java

I have very simple java project, and I'm using gradle to build it.
And I have Linux RedHat server (without access to internet) but this server has access to internal nexus repository where all required dependencies present.
This is build.gradle file:
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'com.github.jacobono.jaxb' version '1.3.5' // this is 14 line
}
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 1.8
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
}
}
buildscript {
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
}
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
}
allprojects {
buildscript {
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
}
}
Settings file settings.gradle:
include 'api'
project(":api").name = "api"
And this project has 1 submodule api filder.
api build.gradle file:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.github.jacobono.jaxb'
springBoot {
buildInfo()
}
group = 'com.example'
version = '1.0.0'
sourceCompatibility = 1.8
repositories {
maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
}
springBoot {
mainClassName = 'com.example.TestApplication'
}
On my linux server I have:
- java 8
- gradle 4.5.1
- mvn 3.5.6
When I'm running gradle clean inside root folder of my project, after 5-10 mins I'm receiving error:
FAILURE: Build failed with an exception.
* Where:
Build file '/my-proj/build.gradle' line: 14
* What went wrong:
Plugin [id: 'com.github.jacobono.jaxb', version: '1.3.5'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.github.jacobono.jaxb:com.github.jacobono.jaxb.gradle.plugin:1.3.5')
Searched in the following repositories:
Gradle Central Plugin Repository
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10m 3s
And for some reason in this error there is no information about my nexus repository...I assuming that it even haven't tried this repository. And the question is why...?
I would be very happy of any help...maybe I made mistake in build.gradle file somewhere...
p.s. on my local pc(I have access to internet and to this repository everything works file)

Plugins by default resolved from Gradle Plugin Portal. If you want to resolve them from different sources, You should add configuration to settings.gradle file.
Example:
pluginManagement {
repositories {
maven {
url '../maven-repo'
}
gradlePluginPortal()
ivy {
url '../ivy-repo'
}
}
}
Check the docs for details.

Related

Error while trying to build gradle project in Intellij Idea

I am trying to accomplish a Java Spring course at Coursera and downloaded the project with this gradle file.
buildscript {
ext {
springBootVersion = '2.1.0.RELEASE'
}
repositories {
maven { url "https://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.2.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
sourceCompatibility = 1.8
targetCompatibility = 1.8
war {
baseName = 'gs-convert-jar-to-war'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/libs-snapshot" }
maven { url "http://maven.springframework.org/milestone" }
flatDir {
dirs 'lib'
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.boot:spring-boot-starter-aop")
compile("org.springframework.boot:spring-boot-starter-test")
compile("org.springframework.boot:spring-boot-starter-jetty")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.data:spring-data-rest-webmvc")
compile("org.apache.httpcomponents:httpclient:4.5.6")
compile("org.hsqldb:hsqldb")
compile("com.google.guava:guava:17.0")
compile("org.apache.commons:commons-lang3:3.3.2")
compile("com.squareup.retrofit:retrofit:1.6.0")
compile("commons-io:commons-io:2.4")
compile("com.github.davidmarquis:fluent-interface-proxy:1.3.0")
compile(":mobilecloud.handin:1.0.0")
compile(":video.up.test:1.0.0")
compile(":autograder.handin:1.0.0")
compile(":autograder.spec:1.0.0")
testCompile("junit:junit")
}
Unfortunately, I have this error in IntelliJ Idea :
A problem occurred configuring root project 'mobile-cloud-asgn1'.
> Failed to notify project evaluation listener.
> org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;
I am quite a newbie to Java and Gradle and never faced errors like this, so I have no idea how to fix it. Can anyone help me?
P.S. Repository with project template: https://github.com/juleswhite/mobile-cloud-asgn1

External gradle plugin 'com.bmuschko.tomcat' not found

I want to add the tomcat plugin to my gradle build, but the plugin cannot be found , gradle shows the error
Plugin with id 'com.bmuschko.tomcat' not found.
I followed the steps on the github page of this plugin, but it does not work.
In my project I have general build.gradle in this I am loading my project.gradle in this I defined the tomcat-plugin configuration.
build.gradle
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = 1.8
ext {
debug = false
}
apply from: 'project.gradle'
group = myGroup
version = myVersion + '-SNAPSHOT'
project.gradle
//https://github.com/bmuschko/gradle-tomcat-plugin
buildscript {
repositories {
jcenter();
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.2'
}
}
apply plugin: "com.bmuschko.tomcat"
apply plugin: "idea"
apply plugin: "project-report"
apply plugin: "war"
I can ensure that dependencies can be resolved from my machine, because other gradle projects work, so that it should not be a network issue, there is no proxy configuration etc.
You have to put buildscript{} into your main build.gradle. The buildscript process is outside the regular Gradle build. Same applies to plugins{} as well (since they are equivalent.)
So if you put
buildscript {
repositories {
jcenter();
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.2'
}
}
into your build.gradle, it would work.
[Update]
I have created a sample gradle project with the fix in it.
And the TravisCI build is here.
Or you may try using the plugin type:
apply plugin: com.bmuschko.gradle.tomcat.TomcatPlugin
instead of
apply plugin: "com.bmuschko.tomcat"
in your project.gradle file.

Error when trying to execute grade publish command

I'm a beginner with gradle and I created an API for mysql and jedis. Now I want to send my project to a artifact repository . I searched how to do that and I fond the solution using "gradle publish". But when I run the command I have an error and I don't realy know why :/
build.gradle:
java
/*
* This build file was auto generated by running the Gradle 'init' task
* by 'ronan' at '12/10/17 21:40' with Gradle 2.10
*/
group 'net.annorit24'
version '1.0-SNAPSHOT'
description 'API for Redis & Msyql'
// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'idea'
sourceCompatibility = 1.8
repositories {
mavenCentral()
mavenLocal()
maven {
url
"https://repository.jboss.org/nexus/content/repositories/thirdparty-
releases"
}
}
configurations {
// configuration that holds jars to include in the jar
extraLibs
}
dependencies {
extraLibs "mysql:mysql-connector-java:5.1.37"
extraLibs group: 'redis.clients', name: 'jedis', version: '2.9.0'
configurations.compile.extendsFrom(configurations.extraLibs)
}
jar {
from {
configurations.extraLibs.collect { it.isDirectory() ? it :
zipTree(it) }
}
}
publishing {
repositories {
maven {
url 'https://mymavenrepo.com/repo/MIz0ZkX9Peab1z9j3ZM8/'
credentials {
username 'myUsername'
password 'myPassword'
}
}
}
publications {
maven(MavenPublication) {
from components.java
}
}
}
Logs : https://pastebin.com/CqDVixy6
If someone have an idea or can help me
Yours faithfully

spring boot gradle plugin in a multi module project - error finding mainClass

I am using Spring boot gradle plugin version 1.5.1 RELEASE as shown below. The build fails at webProject complaining about missing property 'mainClass' and works only when I run 'webProject:build'. Is this the expected usage?
Edit: Updated the build script and removed 'spring-boot' plugin from allProjects. Had to add 'bootRepackage' in web project as it was failing at this step - with the same error. Adding the 'bootRepackage' didn't help.
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
}
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.1.RELEASE")
}
}
plugins {
id 'org.springframework.boot' version '1.5.1.RELEASE'
}
defaultTasks 'clean', 'build'
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = 1.7
targetCompatibility = 1.7
allprojects {
apply plugin: 'java'
//apply plugin: 'org.springframework.boot' -- Commented out based on the answer
repositories {
mavenLocal()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
//all dependencies
}
}
project('aProject') {
dependencies {
compile(project(':bProject'))
}
}
project('webProject') {
apply plugin: 'war'
apply plugin: 'org.springframework.boot'
war {
baseName = 'webProject'
version = '1.0.0-SNAPSHOT'
}
dependencies {
compile(project(':aproject'))
compile(project(':bProject'))
compile 'org.springframework.boot:spring-boot-starter-tomcat'
}
springBoot {
mainClass = 'com.abc.SomeApplication'
}
bootRepackage{
enabled = false
mainClass = 'com.abc.SomeApplication'
}
}
Do not use Spring Boot gradle plugin in main project, only in webProject sub-module.
I have a similar problem in a multi module Spring boot project.
When compiling module A which doesn't have a main class. The main class is in a different module (module B).
I add a plugin in that module A's build.gradle.
apply plugin: 'application'
mainClassName = "module B.ITS_MAIN_CLASS"
Then it works.

gradle build: repo1.maven.org: unknown error

I have a spring-boot app that I was able to start up the server in eclipse.
However, when I goto terminal and do gradle compile, here is the console log i am getting:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'springBootREST'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE.
Required by:
:springBootREST:unspecified
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE.
> Could not get resource 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.2.5.RELEASE/spring-boot-gradle-plugin-1.2.5.RELEASE.pom'.
> Could not HEAD 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.2.5.RELEASE/spring-boot-gradle-plugin-1.2.5.RELEASE.pom'.
> repo1.maven.org: unknown error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I am not entirely sure why this is happening: it seems like it is having some issues with proxy server, but if I were to do wget I can get the files under repo1.maven...
For reference, this is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
// same as what is in my .bash_profile
systemProp.http.proxyHost='my proxy server'
systemProp.http.proxyPort='my proxy port'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'spring-boot'
group = 'lookupGroup'
jar {
baseName = 'lookupService'
version = '0.1.0'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE'
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
Any idea why I can't build?
Proxy properties should be configured in gradle.properties file as stated in the docs.

Categories

Resources