Problem with maven dependencies missing version


(Sverre Moe) #1

Maven is giving me headache with JavaFX. Its failure to create a working JAR JavaFX application. So I thought perhaps try get it working with gradle.

Got problem with maven dependencies from google protobub-java

------------------------------------------------------------
Gradle 3.3
------------------------------------------------------------

Build time:   2017-01-03 15:31:04 UTC
Revision:     075893a3d0798c0c1f322899b41ceca82e4e134b

Groovy:       2.4.7
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_102 (Oracle Corporation 25.102-b14)
OS:           Linux 4.9.9-1.g6c5120c-default amd64

My build.gradle file:

apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'maven'

group = 'com.company' 
version = '1.0.0-SNAPSHOT'

sourceCompatibility = 1.8
targetCompatibility = 1.8

def userName = System.getProperty('user.name')

repositories {
    maven {
        url 'http://companyNexus.com:8081/nexus/content/groups/public'
    }
}

dependencies {
    compile group: 'com.company', name: 'connection-api', version:'1.0.0-SNAPSHOT'
    compile group: 'jsattrak', name: 'jsattrak', version:'4.1.10'
    compile group: 'org.jfxtras', name: 'jfxtras-controls', version:'8.0-r4'
    compile group: 'org.jfree', name: 'jfreechart', version:'1.5.0-SNAPSHOT'
    testCompile group: 'junit', name: 'junit', version:'4.12'
}

Error message trying to build:

:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not resolve com.google.protobuf:protobuf-java:3.0.0-beta-3.
  Required by:
      project : > com.company:connection-api:1.0.0-SNAPSHOT > com.company:myCompany-protobuf-java:2.0.28-SNAPSHOT
   > Could not resolve com.google.protobuf:protobuf-java:3.0.0-beta-3.
      > Could not parse POM http://companyNexus.com:8081/nexus/content/groups/public/com/google/protobuf/protobuf-java/3.0.0-beta-3/protobuf-java-3.0.0-beta-3.pom
         > Unable to resolve version for dependency 'junit:junit:jar'

The com.google.protobuf:protobuf-java does not have a version defined in its pom.xml for its junit dependency or any of the other dependencies:
https://search.maven.org/#artifactdetails|com.google.protobuf|protobuf-java|3.0.0-beta-3|bundle


(Chris Doré) #2

Seems like it could be specific to your nexus server or possibly com.company:connection-api.

I can resolve and compile with this just fine:

apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'maven'

group = 'com.company'
version = '1.0.0-SNAPSHOT'

sourceCompatibility = 1.8
targetCompatibility = 1.8

def userName = System.getProperty('user.name')

repositories {
    jcenter()
}

dependencies {
    compile group: 'com.google.protobuf', name: 'protobuf-java', version:'3.0.0-beta-3'
    testCompile group: 'junit', name: 'junit', version:'4.12'
}

(Chris Doré) #3

Correct, but the parent pom does https://search.maven.org/#artifactdetails|com.google.protobuf|protobuf-parent|3.0.0-beta-3|bundle
Unfortunately I’m not familiar with the details on the behaviours of parent poms and Gradle. The dependencies don’t appear in Gradle’s dependencies task, but I’m not sure if that’s a bug or not.

$ ./gradlew dependencies
:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

archives - Configuration for archive artifacts.
No dependencies

compile - Dependencies for source set 'main'.
\--- com.google.protobuf:protobuf-java:3.0.0-beta-3

compileClasspath - Compile classpath for source set 'main'.
\--- com.google.protobuf:protobuf-java:3.0.0-beta-3

compileOnly - Compile dependencies for source set 'main'.
\--- com.google.protobuf:protobuf-java:3.0.0-beta-3

default - Configuration for default artifacts.
\--- com.google.protobuf:protobuf-java:3.0.0-beta-3

runtime - Runtime dependencies for source set 'main'.
\--- com.google.protobuf:protobuf-java:3.0.0-beta-3

testCompile - Dependencies for source set 'test'.
+--- com.google.protobuf:protobuf-java:3.0.0-beta-3
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

testCompileClasspath - Compile classpath for source set 'test'.
+--- com.google.protobuf:protobuf-java:3.0.0-beta-3
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

testCompileOnly - Compile dependencies for source set 'test'.
+--- com.google.protobuf:protobuf-java:3.0.0-beta-3
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

testRuntime - Runtime dependencies for source set 'test'.
+--- com.google.protobuf:protobuf-java:3.0.0-beta-3
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

(Sverre Moe) #4

I will check the same as you did, and see if the problem is our Nexus and try with jcentral.

Could the problem be with the nested dependency tree. Your example work for a gradle project that directly included the Google protobuf-java.

Oiur JavaFX GUI application has a dependency on our connection-api, which in turn has a dependency to our server-protobuf-java which then depends on the google protobuf-java package.

com.company.javafxApp
– com.company.connection-api
---- com.company.server-protobuf-java
------ com.google.protobuf-java

The connection-api contains the API to connect to our server. The server-protobuf-java contains the Java created class files generated from proto definition files. While protobuf-java from Google contains the Protobuf API and implementation.

All our projects are currently using maven which works fine. Though I want to move over to Gradle.


(Sverre Moe) #5

I deleted the SNAPSHOT version of my com.company.server-protobuf-java from both local maven repository and our Maven Nexus repository.

After that I had no problem running gradle. It didn’t complain about com.google.protobuf-java any more.
Not sure what the problem was, but seems like the SNAPSHOT build perhaps was corrupt or something.