3

I'm new in Gradlew and I have a classes project which I want to import in other Gradle project.

I saw examples with say that first I need create a file settings.gradle where I put for instance

include "projectA"

Then in my build.gradle projectB I put

...
dependencies {
  compile project(":projectA")
  ...
}

However It did not work

Is there a way to use classes from others projects?

arthurfnsc
  • 915
  • 3
  • 13
  • 30
  • How does this "classes" project look like? Do you mean you want to reference the sources of that project or do you just want to reference its binaries (classes or jar)? – Rene Groeschke May 27 '15 at 07:45
  • I want to reference the .java classes... For instance, my first project has an RAML contract. I generate my java interface through an plugin. In my second project I want to create an class which implements the interface in the previous project – arthurfnsc May 27 '15 at 14:56

1 Answers1

0

If you have another project packed into a jar you can do:

compile files('/full/path/to/projectA.jar')
Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
  • Is there other way use other project classes or I must package them into a jar? In maven, for instance, I could add an project as dependency an use its java classes – arthurfnsc May 27 '15 at 15:42
  • If you're using maven-central you can (download and) compile dependencies exactly like in the example you provided. The example that I gave was to use projects that exist only locally (i.e. not published in maven-central). – Nir Alfasi May 27 '15 at 22:59
  • Thx @alfasin, however my case is in two projects that exist locally (not published in maven-central), what I said is that I can put an locally dependency in maven projects too. – arthurfnsc May 27 '15 at 23:26