0

So I have a GitHub repo and I want to supplement it with other projects in other repos. I am using Eclipse and Java as my dev tools. Is there a video I can watch or a tutorial? I've looked on YouTube and Googled the problem -- I'm probably not building a proper query so find what I need.

I don't want to merge two repos into one repo. I want to incorporate the code in another repo into an Eclipse project on my dev machine that uses one of my repos. I think.

TylerH
  • 19,065
  • 49
  • 65
  • 86
nicomp
  • 3,775
  • 4
  • 19
  • 43
  • You'd do a great service to yourself if you spent some quality time with Google. I can see that the biggest problem of the younger generation seems to be that they don't know how to look for information. You can't expect other people to be holding your hand all the time. – Kayaman Dec 14 '15 at 18:55
  • Possible duplicate of [How do you merge two git repositories?](http://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories) – kmonsoor Dec 14 '15 at 18:58
  • Also, tutorial requests are off-topic. – Ajean Dec 14 '15 at 19:08
  • Do you wish to use other projects as dependencies for your project? – Indrek Ots Dec 14 '15 at 19:10
  • @Kayaman I'll get off your lawn. – nicomp Dec 14 '15 at 19:20
  • 1
    Have you looked into build tools (e.g. Maven, Gradle)? They let you specify which projects you want to depend on. During build time, these projects are added to your class path. – Indrek Ots Dec 14 '15 at 19:27
  • @IndrekOts I will do that, thank you. As soon as I get off Kayman's lawn. – nicomp Dec 14 '15 at 19:29
  • @nicomp I don't have a lawn. I meant that as genuine advice to you. You may not like it (and the tone may have not been the nicest), but can you dismiss an experienced developer's suggestion? – Kayaman Dec 14 '15 at 19:37
  • @Kayaman I have no doubt you are sincere. – nicomp Dec 14 '15 at 19:39

1 Answers1

2

If I'm understanding you correctly, you wish to use other projects/libraries in your project. You should look into Java build tools (ev. Maven, Gradle and others). Among other things, they let you specify a list of dependencies for your project.

Maven example

First of all, you should set up your project to use Maven.

For instance, if you wish to use joda-time (a popular date and time library for Java), you could go to http://mvnrepository.com/ and look for joda-time. From there select your desired version and copy-paste the Maven dependency to your pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.myproject</groupId>
  <artifactId>myproject</artifactId>
  <version>0.1-SNAPSHOT</version>

  <dependencies>
      <dependency>
          <groupId>joda-time</groupId>
          <artifactId>joda-time</artifactId>
          <version>2.9.1</version>
      </dependency>
  </dependencies>

</project>

Now when you call mvn clean install from your commandline or use the Maven Eclipse plugin, your project is built and the dependencies you specified are downloaded and added to your class path.

Keep in mind, the source code for the dependencies is never added to your project, only the jar files are added to your class path.

Indrek Ots
  • 2,781
  • 1
  • 14
  • 24