Can't connect to my nexus repository by using gradle - java

I've got following build.gradle file:
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'eclipse'
buildscript {
repositories {
maven {
url "<myURL>/nexus/content/groups/public"
}
}
dependencies {
}
}
jar {
baseName = 'myAppName'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
maven {
url "<myURL>/nexus/content/groups/public/"
credentials {
username "nexusUser"
password "nexusPassword"
}
}
maven {
url "<myURL>/nexus/content/repositories/snapshots"
credentials {
username "nexusUser"
password "nexusPassword"
}
}
}
dependencies {
compile group: 'javax', name: 'javaee-api', version: '7.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5'
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.10.19'
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "<myURL>/content/repositories/releases") {
authentication(userName: nexusUsername, password: nexusPassword)
}
snapshotRepository(url: "<myURL>/nexus/content/repositories/snapshots") {
authentication(userName: nexusUsername, password: nexusPassword)
}
pom.version = "0.0.1-SNAPSHOT"
pom.artifactId = "app-name-commons"
pom.groupId = "de.commons"
}
}
}
My Problem is that I can't neither upload artifacts to my nexus repo nore I get the dependencies like javaee-api etc. The credential are defined in a gradle.properties file. Has anybody a hint why this doesn't work?
Update
If I make the repositories readable for anonymous users i get the dependencies. So it seems the problem is the login.

Related

Gradle Spring Boot Junit | Logging | Debugging

I am introducing Junit tests in one of our projects but unfortunately am getting a null pointer exception but I can't tell where is it thrown, when trying to debug the debugger does not stop in my break point. I am testing a spring boot application
Can you assist I am not familiar with gradle maybe I missed a certain config, below is my gradle file
buildscript {
ext {
springBootVersion = '2.2.11.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://artifacts.company.com/artifactory/appsmav-main-maven-local/"
credentials {
username "${artifactory_user}"
password "${artifactory_password}"
}
}
maven {
url "https://plugins.gradle.org/m2/"
}
// flatDir {
// dirs '/Users/pabu/workspaces/intellij/companyikat7/PlantumlPlugin/build/libs'
// }
}
repositories { flatDir name: 'libs', dirs: "../build/libs" }
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-RC3'
classpath 'org.reflections:reflections:0.9.11'
classpath 'io.company.gradle.plugins:PlantumlPlugin:1.0.7'
classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:2.2.4"
classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'io.company.gradle.plugins.plantuml'
apply plugin: 'com.gorylenko.gradle-git-properties'
apply plugin: "com.github.ManifestClasspath"
group = 'io.company'
version = '0.0.2'
sourceCompatibility = "11"
repositories {
jcenter()
mavenCentral()
maven {
url "https://artifacts.company.com/artifactory/appsmav-main-maven-local/"
credentials {
username "${artifactory_user}"
password "${artifactory_password}"
}
}
}
springBoot {
buildInfo {
properties {
artifact = 'company-core-service'
name = 'company'
}
}
}
configurations {
providedRuntime
compile.exclude module: 'slf4j-simple'
compile.exclude module: "spring-boot-starter-tomcat"
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-jetty')
compileOnly('org.springframework.boot:spring-boot-devtools')
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-freemarker
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-freemarker', version: '2.5.3'
implementation 'io.micrometer:micrometer-core:1.5.7'
implementation 'io.micrometer:micrometer-registry-prometheus:1.5.7'
implementation 'io.sentry:sentry-spring-boot-starter:3.2.0'
implementation 'io.sentry:sentry-logback:3.2.0'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.8.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.8.0'
compile group: 'com.unboundid', name: 'unboundid-ldapsdk', version: '4.0.0'
runtime('org.postgresql:postgresql')
compile('io.company.commons:commons-utils:1.+') {
exclude group: 'org.slf4j'
}
compile('io.company.commons:commons-api:1.3.0') {
exclude group: 'org.slf4j'
}
// https://mvnrepository.com/artifact/org.springframework.retry/spring-retry
compile group: 'org.springframework.retry', name: 'spring-retry', version: '1.3.0'
// Azure Notification Hub SDK
compile group: 'com.windowsazure', name: 'Notification-Hubs-java-sdk', version: '0.1.0'
// https://mvnrepository.com/artifact/javax.json/javax.json-api
compile group: 'javax.json', name: 'javax.json-api', version: '1.1.4'
// https://mvnrepository.com/artifact/org.glassfish/javax.json
compile group: 'org.glassfish', name: 'javax.json', version: '1.1.4'
implementation 'com.sun.mail:javax.mail:1.6.2'
// compile project(":commons-api-local")
compile('io.company.commons:commons-io:1.3.0') {
exclude group: 'org.slf4j'
}
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'io.company.commons', name: 'commons-jwt', version: '1.0.8'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
// https://projectlombok.org
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
testImplementation('org.junit.jupiter:junit-jupiter:5.5.1')
}
test {
useJUnitPlatform {
excludeTags "integration"
}
testLogging.showStandardStreams(true);
testLogging {
events "passed", "skipped", "failed"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true
}
}
In the log below I can't tell where is the NullPointerException thrown
16:38:55.075 [main] DEBUG org.springframework.ui.freemarker.SpringTemplateLoader - Looking for FreeMarker template with name [DisruptionOverviewBody_en.ftlh]
16:38:55.076 [main] DEBUG org.springframework.ui.freemarker.SpringTemplateLoader - Looking for FreeMarker template with name [DisruptionOverviewBody.ftlh]
Failures (1):
JUnit Jupiter:DisruptionEventControllerTest:shouldCreateNewDisruptionEvent()
MethodSource [className = 'ui.controller.DisruptionEventControllerTest', methodName = 'shouldCreateNewDisruptionEvent', methodParameterTypes = '']
=> java.lang.NullPointerException
Test run finished after 1639 ms

I have an error but dependencies include in gradle root and gradle module config, why?

I have root config gradle.build
plugins {
id 'org.springframework.boot' version '2.3.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'idea'
}
idea {
project {
languageLevel = 14
}
module {
downloadJavadoc = true
downloadSources = true
}
}
allprojects {
group "ru.otus"
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
apply plugin: "io.spring.dependency-management"
dependencyManagement {
dependencies {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.3.5.RELEASE")
}
dependency("org.projectlombok:lombok:1.18.16")
dependency("org.springframework.shell:spring-shell-starter:2.0.1.RELEASE")
dependency("org.springframework.boot:spring-boot-starter-data-jpa:2.3.5.RELEASE")
dependency("org.flywaydb:flyway-core:6.4.4")
dependency("org.postgresql:postgresql:42.2.16")
dependency("org.hamcrest:hamcrest-core:1.3")
dependency("org.springframework.boot:spring-boot-starter-test:2.3.5.RELEASE")
}
}
configurations.all {
resolutionStrategy {
failOnVersionConflict()
}
resolutionStrategy {
force("javax.servlet:servlet-api:2.4")
force("commons-logging:commons-logging:1.1.1")
force("commons-lang:commons-lang:2.5")
force("org.codehaus.jackson:jackson-core-asl:1.8.8")
force("org.codehaus.jackson:jackson-mapper-asl:1.8.3")
force("org.codehaus.jettison:jettison:1.1")
force("org.javassist:javassist:3.24.0-GA")
force("org.apiguardian:apiguardian-api:1.1.0")
force("org.opentest4j:opentest4j:1.2.0")
}
}
}
and have build.gradle in module
plugins {
id 'java'
}
version = '0.0.1-SNAPSHOT'
dependencies {
implementation group: 'org.springframework.shell', name: 'spring-shell-starter', version: '2.0.1.RELEASE'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter', version: '2.3.5.RELEASE'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '6.4.4'
testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.3.5.RELEASE'
}
After download dependencies and add in models annotations like #Entity, #Table #Id and etc. i have an error: cannot find symbol
#Entity
^
symbol: class Entity
But i have spring-boot-starter-jpa in dependencies, i don't know why in module i can't use dependencies.
With dependencyManagement you only manage dependencies like version, overrides etc. you don't actually add dependencies to a project. For that use dependencies like you use in the other places.

Generate generated folder when starting springboot netty

I am studying spring webflux, but the generated folder is created when the server starts. Do you know why?
If you restart the server after deleting the generated folder, it will be created again.
The build.gradle file was configured as follows.
spring boot 2.2.7.RELEASE version and using jdk 8.
build.gradle
buildscript {
ext {
restDocsVersion = "2.0.2.RELEASE"
}
dependencies {
classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.5.3"
}
}
plugins {
id "org.springframework.boot" version "2.2.7.RELEASE"
id "io.spring.dependency-management" version "1.0.9.RELEASE"
id "java"
id "groovy"
id "org.asciidoctor.convert" version "2.4.0"
}
ext {
snippetsDir = file("build/generated-snippets")
}
test {
useJUnitPlatform()
}
asciidoctor {
inputs.dir snippetsDir
dependsOn test
}
bootJar {
dependsOn asciidoctor
from("${asciidoctor.outputDir}/html5") {
into "static/docs"
}
dependsOn "copyDocs"
}
task copyDocs(type: Copy) {
from "${asciidoctor.outputDir}/html5"
into "src/main/resources/static/docs"
}
group = "com.example"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
build {
dependsOn clean
}
repositories {
mavenCentral()
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-aop"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-webflux"
compile "org.springframework.boot:spring-boot-starter-data-redis-reactive"
compileOnly "org.projectlombok:lombok"
annotationProcessor "org.projectlombok:lombok"
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude group: "org.junit.vintage", module: "junit-vintage-engine"
}
testImplementation "io.projectreactor:reactor-test"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
compile group: "com.fasterxml.jackson.core", name: "jackson-core", version: "2.9.8"
compile group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: "2.9.8"
compile group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.9.8"
compile group: "com.googlecode.json-simple", name: "json-simple", version: "1.1.1"
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:${restDocsVersion}"
testCompile "org.springframework.restdocs:spring-restdocs-webtestclient:${restDocsVersion}"
compile group: "org.codehaus.groovy", name: "groovy-all", version: "2.5.8"
}

Gradle Multiproject - OpenClover

I am trying to integrate Open Clover into my Gradle build process and was following the following guide:
When I added it to my build.gradle - I got the following error:
* * What went wrong:
A problem occurred evaluating root project 'Enjin-Coin-Java-SDK'.
> Could not find method cloverCompile() for arguments [org.openclover:clover:4.2.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler..
My build.gradle file is as follows:
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'org.openclover:clover:4.2.0'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.4'
id 'java'
}
sourceSets {
clover {
java {
srcDir "$buildDir/sources-instr"
}
}
}
apply from: 'gradle/util.gradle'
subprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
group = 'com.myproject'
version = '0.0.1-SNAPSHOT'
idea {
module {
scopes.PROVIDED.plus += [configurations.shadow]
}
}
tasks.build.dependsOn(shadowJar)
artifacts.archives shadowJar
tasks.withType(AbstractCompile) {
classpath += configurations.shadow
}
ext {
mockito = '2.9.0'
junit = '4.12'
powermock = '1.7.3'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
// testCompile dependencies
testCompile group: 'org.mockito', name: 'mockito-core', version: mockito
testCompile group: 'junit', name: 'junit', version: junit
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: powermock
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: powermock
cloverCompile 'org.openclover:clover:4.2.0'
}
jar {
archiveName = "${project.name}-slim.jar"
}
shadowJar {
archiveName = "${project.name}.jar"
}
install {
repositories.mavenInstaller {
pom.artifactId = "sdk-${project.name}"
}
}
}
configurations {
cloverRuntime
cloverRuntime.extendsFrom cloverCompile
}
task cloverInstr() {
inputs.files sourceSets.main.allJava
outputs.dir "$buildDir/sources-instr"
doFirst {
def argsList = ["--initstring", "${buildDir}/clover/clover.db", "-d", "${buildDir}/sources-instr"]
argsList.addAll(inputs.files.files.collect({ file ->
file.absolutePath
}))
String[] args = argsList.toArray()
com.atlassian.clover.CloverInstr.mainImpl(args)
}
}
cloverClasses.dependsOn cloverInstr
test {
def cloverClasspath = configurations.testRuntime + configurations.cloverRuntime + sourceSets.test.output + sourceSets.clover.output
classpath = cloverClasspath
}
task cloverReport {
inputs.dir "${buildDir}/clover"
outputs.dir "${reportsDir}/clover"
onlyIf {
file("${buildDir}/clover/clover.db").exists()
}
doFirst {
def argsList = ["--initstring", "${buildDir}/clover/clover.db",
"-o", "${reportsDir}/clover"]
String[] args = argsList.toArray()
com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
}
}
The contents of util.gradle are as follows
ext.scriptFile = {
String fileName ->
return new File(new File(rootDir, 'gradle'), fileName)
}
Can anyone offer any assistance in how to resolve this?
Use the following script to integrate clover into your project:
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
jcenter()
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.4'
id "com.bmuschko.clover" version "2.1.3"
}
apply from: 'gradle/util.gradle'
subprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.bmuschko.clover'
group = 'com.myproject'
version = '0.0.1-SNAPSHOT'
idea {
module {
scopes.PROVIDED.plus += [configurations.shadow]
}
}
tasks.build.dependsOn(shadowJar)
artifacts.archives shadowJar
tasks.withType(AbstractCompile) {
classpath += configurations.shadow
}
ext {
mockito = '2.9.0'
junit = '4.12'
powermock = '1.7.3'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
// testCompile dependencies
testCompile group: 'org.mockito', name: 'mockito-core', version: mockito
testCompile group: 'junit', name: 'junit', version: junit
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: powermock
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: powermock
clover 'org.openclover:clover:4.2.0'
}
jar {
archiveName = "${project.name}-slim.jar"
}
shadowJar {
archiveName = "${project.name}.jar"
}
install {
repositories.mavenInstaller {
pom.artifactId = "sdk-${project.name}"
}
}
}
There's no need for manual integration if ready-to-use plugin is available.

My gradle spring project on intellij taking too long to refresh

I am using Intellij IDEA 2017.1.4. I am new to gradle. I have been given a multi modular spring project on Gradle. Problem is when I do "Refresh all gradle projects" (on the side pan of IDEA), it takes hours. Some times a day. It is necessary for me sometimes doing refresh due to addition of dependencies or something else.
Following is my root build.gradle file. Please help.
group 'tv.videoready'
version = "1.0.0-RELEASE"
description = "Mobile/Web API's Application"
buildscript {
ext {
springBootVersion = '1.4.0.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.17")
}
}
apply plugin: 'idea'
apply plugin: "com.gorylenko.gradle-git-properties"
jar {
baseName = 'rest-api'
version = '1.0.0-RELEASE'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url 'http://artifactory.videoready.tv/artifactory/libs-release-local' }
maven { url 'http://artifactory.videoready.tv/artifactory/libs-snapshot-local' }
}
gitProperties {
dateFormat = "d MMM yyyy HH:mm:ss Z"
dateFormatTimeZone = "UTC"
gitRepositoryRoot = new File("${project.rootDir}")
gitPropertiesDir = new File("${project.rootDir}/src/main/resources")
}
ext {
springBootVersion = "1.4.0.RELEASE"
mysqlConnectorVersion = '5.1.39'
swaggerVersion = '2.7.0'
}
dependencies {
// Actuator
compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
compile 'org.springframework.hateoas:spring-hateoas:0.20.0.RELEASE'
compile project(":login")
compile project(":config")
compile project(":device")
compile project(":password")
compile project(":sms")
compile project(":remote-record")
compile project(":otp")
compile project(":profile")
compile("de.codecentric:spring-boot-admin-starter-client:1.4.4")
}
allprojects {
apply plugin: 'java'
apply plugin: 'spring-boot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url 'http://artifactory.videoready.tv/artifactory/libs-release-local' }
maven { url 'http://artifactory.videoready.tv/artifactory/libs-snapshot-local' }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-jetty:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-amqp:${springBootVersion}")
compile("mysql:mysql-connector-java:${mysqlConnectorVersion}")
compile group: 'org.hibernate', name: 'hibernate-validator', version: '4.3.2.Final'
//HTTP Client
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.5'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
compile(group: 'tv.videoready', name: 'module-logger', version: '2.0.2-RELEASE')
compile(group: 'tv.videoready', name: 'cors-filter', version: '1.0.0')
// compile(group: 'tv.videoready', name: 'common-sql-domains', version: '1.5.8-SNAPSHOT')
compile files("/home/divya/projects/tatasky/common-services/common-sql-domains/build/libs/ common-sql-domains-3.1.0-RELEASE.jar")
compile(group: 'tv.videoready', name: 'mm-domains', version: '3.1.4-SNAPSHOT')
compile(group: 'tv.videoready', name: 'common-constants', version: '1.4.10-SNAPSHOT')
compile(group: 'tv.videoready', name: 'domain-pojo-utils', version: '1.2.0-SNAPSHOT')
compile(group: 'tv.videoready', name: 'validation-util', version: '1.2.0-SNAPSHOT')
compile(group: 'tv.videoready', name: 'search-client', version: '1.4.4-SNAPSHOT'){
exclude(group: 'tv.videoready', module: 'common-constants')
exclude(group: 'tv.videoready', module: 'common-sql-domains')
exclude(group: 'tv.videoready', module: 'mm-domains')
}
compile(group: 'tv.videoready', name: 'common-pojo', version: '1.3.23-SNAPSHOT')
compile(group: 'tv.videoready', name: 'i-spy-client', version: '1.0.2-SNAPSHOT')
compile(group: 'tv.videoready', name: 'cache', version: '2.0.26-SNAPSHOT')
compile('com.hazelcast:hazelcast:3.7.5')
compile('com.hazelcast:hazelcast-client:3.7.5')
compile("io.springfox:springfox-swagger2:${swaggerVersion}")
compile("io.springfox:springfox-swagger-ui:${swaggerVersion}")
}
configurations {
compile.exclude module: ("spring-boot-starter-tomcat")
compile.exclude module: ("spring-boot-starter-logging")
}
sourceSets.main.resources {
srcDir '../src/main/resources'
}
}
subprojects {
group = 'tv.videoready'
version = '1.0.0-RELEASE'
}
processResources {
filesMatching("**/application.properties") {
expand(project.properties)
}
}
bootRun {
systemProperties = System.properties
systemProperty "log4j.configurationFactory", "tv.videoready.logger.LoggingConfigurationFactory"
systemProperty "mockRRM", true
systemProperty "dev.hazelcast.setup.enabled", "false"
systemProperty "dev.hazelcast.cluster.group.password", "hari"
systemProperty "hazelcast.cluster.group.password", "hari"
systemProperty "spring.config.location", "classpath:hazelcast-dev.properties"
systemProperty "jsse.enableSNIExtension", "false"
}

Categories