auto gradle downloading from svn repository - java

I have problems with configure my build.gradle for download jar and pom from svn repository. For example, i have url:
https://svn.code.sf.net/p/springframework/svn/repos/repo-ext/javax/xml/crypto/xmldsig/1.0/
and i want did like this compile group: 'com.sun.xml.wss', name: 'xws-security', version: '3.0'
Also, manual download is wrong way.
UPD this is build.gradle file of backend project
apply plugin: 'java'
dependencies {
compile group: 'org.glassfish.metro', name: 'wssx-api', version: '2.1.1-b09'
compile group: 'com.sun.xml.wss', name: 'xws-security', version: '3.0'
compile project(':pp-backend')
}

If you're not downloading from maven central (which is configured in Gradle by default), you should configure the repository to download from using the 'repositories' closure:
repositories {
mavenCentral()
maven {
url 'https://svn.code.sf.net/p/springframework/svn/repos/repo-ext/'
}
}
Then, in the 'dependencies' closure, just add:
compile group: 'javax.xml.crypto', name: 'xmldsig', version: '1.0'
See more info in Dependency Management Basics

Related

Multiple Repositories in build.gradle is not working (jzy3d) (MultiModuleProject)

I've got a problem with my Java project in gradle. I'm using several dependencies with gradle, one of it is the jzy3d.api. I have included it in the build.gradle file and added the url to the repositories but it doesn't find it. I've added the repository for it as it is located here: http://maven.jzy3d.org/releases/org/jzy3d/jzy3d-api/1.0.2/
But the Error Message seems like that it isn't searching there. Can please someone tell me why?
Here is my build.gradle and the Error Message:
plugins {
id 'java'
id 'idea' // optional, for IntelliJ IDEA project
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
maven {
url "https://maven.jzy3d.org/releases"
}
mavenCentral()
}
dependencies {
testCompile 'org.junit.jupiter:junit-jupiter:5.6.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
compile group: 'org.jzy3d', name: 'jzy3d-api', version: '1.0.2'
compile group: 'org.jfree', name: 'jfreechart', version: '1.5.0'
}
Execution failed for task ':BusinessLayer:compileJava'.
> Could not resolve all files for configuration ':BusinessLayer:compileClasspath'.
> Could not find org.jzy3d:jzy3d-api:1.0.2.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/jzy3d/jzy3d-api/1.0.2/jzy3d-api-1.0.2.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :BusinessLayer > project :DataLayer
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
When I'm adding something to the url, for example url "https://maven.jzy3d.org/releases/maven2" the Error Message says:
Could not find org.jzy3d:jzy3d-api:1.0.2.
Searched in the following locations:
- https://maven.jzy3d.org/releases/maven2/org/jzy3d/jzy3d-api/1.0.2/jzy3d-api-1.0.2.pom
- https://repo.maven.apache.org/maven2/org/jzy3d/jzy3d-api/1.0.2/jzy3d-api-1.0.2.pom
So I think that for some reason it don't want to search in the https://maven.jzy3d.org/releases directory...

Gradle: publish existing jar/source/javadoc to maven

I have some proprietary libraries which are used in my java project. I use gradle as build manager. I use the eclipse-ide.
Since I dont want to have any binaries in my repo, I created a custom maven repository. Prior to Gradle 6.x Gradle just downloaded the .jar file with the correct folder structure in the repository (GROUPNAME/ARTIFACT/VERSION/... .jar)
After I updated to Gradle 6.5 Gradle wanted a .pom file to specify the jar. So I created a dummy project with this build file and used the command gradle install to get the .pom file.
plugins {
id 'java-library'
id 'maven'
}
repositories {
jcenter()
}
dependencies {
api group: 'commons-codec', name: 'commons-codec', version: '1.10'
api group: 'commons-logging', name: 'commons-logging', version: '1.2'
api group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
api group: 'log4j', name: 'log4j', version: '1.2.17'
}
install {
repositories.mavenInstaller {
pom.version = '...'
pom.groupId = '...'
pom.artifactId = '...'
}
}
With this method I had to rename the library jar accordingly. Now I have the .pom file but missing all the md5/sha/metafile/... files which are normaly generated with the maven-publish plugin.
I either need to know how to configure my dummy project to generate the md5/sha/metafile/... without having the source code - just have the .jar/sources.jar/javadoc.jar
OR I need to know how to configure my normal build to download the javadoc/sources withouth the correct .pom file

NoClassDefFoundError on Spring application

Full error is in this image as I am running on virtual machine in cloud which is access via video feed so I cannot copy and paste.This is a fresh install of ubuntu where I have only installed JDK and nothing else so unaware if other setup needs to be done
https://imgur.com/a/egJ3d
It is a spring boot application.
My build.gradle
group 'com.haughon.daniel'
version '1.0-SNAPSHOT'
buildscript {
repositories{
mavenCentral()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE'
}
}
// Apply the Spring Boot plugin
apply plugin: 'spring-boot'
// Apply the Java plugin (expects src/main/java to be source folder)
apply plugin: 'java'
apply plugin: 'idea'
// Specify the location where our dependencies will be found
repositories {
mavenCentral()
}
jar {
manifest {
attributes 'Main-Class': 'haughton.dvdstore.Application'
attributes 'addClasspath': 'true'
}
}
// Specify dependencies
dependencies {
compile 'org.hashids:hashids:1.0.1'
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile 'org.springframework:spring-orm:4.3.7.RELEASE'
compile 'org.hibernate:hibernate-core:5.2.9.Final'
compile 'org.hibernate:hibernate-entitymanager:5.0.6.Final'
compile 'org.apache.tomcat:tomcat-dbcp:8.0.30'
compile 'org.springframework.boot:spring-boot-starter-security'
compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4')
//compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity:3.0.2.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.11.1.RELEASE'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'
runtime 'com.h2database:h2'
runtime 'javax.transaction:jta:1.1'
runtime 'org.aspectj:aspectjweaver:1.8.7'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}
This is because your dependencies are not included in one jar file.
use ./gradlew clean build
please see this post:
java.lang.NoClassDefFoundError: when trying to run jar

Gretty: Duplicate fragment name: org_apache_jasper

I use gretty to easily run a dev server and webapp-runner for deployment to heroku.
The following is my gradle.build:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:+'
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'org.akhikhl.gretty'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-webmvc:4.3.10.RELEASE'
compile 'org.springframework:spring-orm:4.3.10.RELEASE'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.0'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.10.Final'
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.1.1'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.1.Final'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
compile 'com.github.jsimone:webapp-runner:8.5.11.3'
}
gretty {
httpPort = 8080
servletContainer = 'jetty9'
contextPath = '/'
}
eclipse {
wtp {
component {
contextPath = '/'
}
}
}
///////// Tasks for deployment to heroku
task stage() {
dependsOn clean, war
}
war.mustRunAfter clean
task copyToLib(type: Copy) {
dependsOn war
into "$buildDir/server"
from(configurations.compile) {
include "webapp-runner*"
}
}
stage.dependsOn(copyToLib)
If I remove webapp-runner everything runs fine, but with it I get the following error when trying to start gretty:
java.lang.IllegalStateException: Duplicate fragment name: org_apache_jasper for jar
Not an expert but I figure its something to do with the fact that both gretty and webapp-runner download similar files and that's causing a clash?
Would really appreciate some info on this. How do I get past this? Is there a better way to have a dev server + be able to deploy to heroku? (maybe use webapp-runner for both?)
I recommend running locally the same way as Heroku runs your app, with these commands:
$ ./gradlew stage
$ heroku local web
If you want to use gretty for development, you'll need to exclude webapp-runner from your dev build (maybe with a stageDev task), and exclude gretty from your stage build.

gradle unable to find artifact in maven repository

I am doing a simple gradle build and I have deployed a particular artifact to my internal sonatype maven repo
My build.gradle file looks like this:
apply plugin: 'java'
sourceCompatibility = 1.8
version = '1.0'
repositories {
mavenCentral()
maven {url "http://maven.ebay.com/nexus/content/repositories/sre-snapshots/"}
}
dependencies {
compile group: "com.typesafe", name: "config", version: "1.3.0"
//compile project(':metrics')
compile group: 'com.ebay.telemetry', name: 'client-library', version: '0.1-SNAPSHOT'
compile group: "org.slf4j", name: "slf4j-jdk14", version: "1.7.12"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
I run this command on the command line: gradle build
I get this error:
> Could not find net.alchim31:metrics-influxdb:0.7.1-ebay-SNAPSHOT.
Searched in the following locations:
https://repo1.maven.org/maven2/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/metrics-influxdb-0.7.1-ebay-20150708.054833-4.pom
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/metrics-influxdb-0.7.1-ebay-20150708.054833-4.jar
However when I go to http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/
I see the following files :
metrics-influxdb-0.7.1-ebay-20150708.054830-3.pom
metrics-influxdb-0.7.1-ebay-20150708.054830-3.jar
So why is gradle looking for metrics-influxdb-0.7.1-ebay-20150708.054833-4.jar when my repo has metrics-influxdb-0.7.1-ebay-20150708.054830-3.jar
It seems like you have declared another dependency besides the one you showed above. It should probably look something like this:
compile group: 'net.alchim31', name: 'metrics-influxdb', version: '0.7.1-ebay-SNAPSHOT'
If you find this dependency declaration, you might also find the source of the problem.
The second possibility is, that your maven-metadata.xml (at http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml) is messed up and points towards the nonexisting build 4.

Categories