Nexus Dependency is not downloaded


(Andreas Sotirakopoulos) #1

Hi there,

I have the gradle.build:

/*
* This build file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* user guide available at https://docs.gradle.org/4.3/userguide/java_library_plugin.html
*/

// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'
apply plugin: 'maven'

// In this section you declare where to find the dependencies of your project
repositories {
 // Use jcenter for resolving your dependencies.
 // You can declare any Maven/Ivy/file repository here.
 jcenter()


maven {
   credentials {
      username 'username'
      password 'pass'
    }
  url "https://mydomain/repository/shared/"
 }
}

dependencies {

    //THIS IS WHAT I NEED DOWNLOADED
compile 'my.domain.libs.api:mobile:0.0.7'

// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:23.0'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}

But the dependency is not being downloaded. I don’t even get an error that gradle cannot log in nexus. Of course the classes are not found when I try to use them in my app. And gradle build fails


(Benjamin Muschko) #2

Dependencies are only downloaded if if they are needed to fulfill work. What exactly were you looking for? For output in the console? For the dependency to be downloaded you will have have to compile the code by running compileJava for existing source files.

You will need to provide more information e.g. the console output or error you are seeing.


(Andreas Sotirakopoulos) #3

In main I have the following:

package io.commxp.gradle.test.app;

import io.commxp.libs.api.mobile;

public class Application {

public static void main(String... args) {
	System.out.println("Hello Gradle");
	
	SubscriberData s = new SubscirberData();
}

}

And SubscriberData is a class inside the jar I am trying to add a dependency. When I give the command gradle compileJava I get the error:

Starting a Gradle Daemon (subsequent builds will be faster)

Task :compileJava FAILED
/home/ubuntu/eclipse-workspace/io.commxp.gradle.test/src/main/java/io/commxp/gradle/test/app/Application.java:6: error: package io.commxp.libs.api does not exist
import io.commxp.libs.api.mobile;
^
/home/ubuntu/eclipse-workspace/io.commxp.gradle.test/src/main/java/io/commxp/gradle/test/app/Application.java:17: error: cannot find symbol
SubscriberData s = new SubscirberData();
^
symbol: class SubscriberData
location: class Application
/home/ubuntu/eclipse-workspace/io.commxp.gradle.test/src/main/java/io/commxp/gradle/test/app/Application.java:17: error: cannot find symbol
SubscriberData s = new SubscirberData();
^
symbol: class SubscirberData
location: class Application
3 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:compileJava’.

Compilation failed; see the compiler error output for details.

  • 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 2s
1 actionable task: 1 executed

This is what I am not getting


(Benjamin Muschko) #4

In your import statement you actually have to declare a class or pull in everything with a *.


(Andreas Sotirakopoulos) #5

You are of course right. But the problem is not there. I don’t have any gradle experience but once the dependency is in maven Eclipse resolves the needed dependencies.

In this case it does not work. I do not see the jar in the Project and External Dependencies like I see the junit-4.12.jar, for example, as I expected from the testImplementation 'junit:junit:4.12' line in the build.gradle.

To test I added the import by hand correctly and tried again but again I get the error

Task :compileJava FAILED
/home/ubuntu/eclipse-workspace/io.commxp.gradle.test/src/main/java/io/commxp/gradle/test/app/Application.java:17: error: cannot find symbol
SubscriberData s = new SubscirberData();
^
symbol: class SubscirberData
location: class Application
1 error

FAILURE: Build failed with an exception.


(Benjamin Muschko) #6

I don’t quite understand that comment. Are you running the build in Eclipse? I’d suggest to try it out on the command line first to ensure it works in general. Do you use Buildship in Eclipse?

BTW: You have a typo in SubscirberData.


(Andreas Sotirakopoulos) #7

Ok there is something strange going on here.

My application is just one class:

import io.commxp.libs.api.mobile.subscriber.SubscriberData;

public class Application {

public static void main(String... args) {
	System.out.println("Hello Gradle");
	
	SubscriberData subData = SubscriberData();
}
}

And my build.gradle file is as of below:

	apply plugin: 'java-library'
apply plugin: 'maven'

// In this section you declare where to find the dependencies of your project
repositories {
 // Use jcenter for resolving your dependencies.
 // You can declare any Maven/Ivy/file repository here.
 jcenter()


maven {	
   credentials {
      username 'username'
      password 'password'
    }
  url "https://my.domain.com/repository/shared/"
 }
}

dependencies {

	//THIS IS WHAT I NEED DOWNLOADED
compile 'io.commxp.libs.api:mobile:0.0.7'

// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:23.0'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}

When I go to my linux command line where Gradle 4.4.1 is installed and I give the command gradle compileJava I see the following error:

ubuntu@ubuntu-laptopt: ~/eclipse-workspace/test $ gradle compileJava

Task :compileJava FAILED
/home/ubuntu/eclipse-workspace/test/src/main/java/test/Application.java:10: error: cannot find symbol
SubscriberData subDate = SubscriberData();
^
symbol: method SubscriberData()
location: class Application
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:compileJava’.

Compilation failed; see the compiler error output for details.

  • 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 0s
1 actionable task: 1 executed

Is something that I am doing wrong?