Using eGIT I can successfully clone a GIT repo.
I can also import (as maven module), the multi-module project (by selecting the parent pom) into eclipse. As per best practise, my local workspace and GIT repo are in separate directories. I can make changes to existing classes / packages (i.e. add, commit and push to GIT origin on GitHub), and am starting to understand the GIT workflow...
What I cant figure out is how to add a new java project to the multi-module project? Should I create in GitHub first?
Other Config:
- Local GIT repository (i.e. where I created clone):
c:\dev\gitrepos\xxx-api-client.git
Local Workspace (i.e. my workapce where I imported clone into - which btw is ):
c:\dev\apis
I do have write access to then GIT repo
If I understand your question correctly and you are using Maven as a build tool ,then I don't think you have to add separately in your repository , GIT will automatically take care of that.
Only thing you have to do create a new module and declare that in your parent pom file like this.
<modules>
<module>module1</module>
<module>module2</module>
<module>your_new_module</module> </modules>
Now next time when you do a commit , you have to add this pom file. From there onwards it will be a part of your repository and whenever anybody do a clone it will be available.
Please correct me if i have not understand your question correctly.
Related
I want to create a new Maven project in Eclipse and push it to a new repository on github. I am a bit stuck on the right order of steps to achieve this.
To use a Maven archetype, I cannot use a directory with files in it. So I cannot create a Maven project in a git local repository. So using the archetype should probably come first.
I also need to create a repository in my github account. If I do this through the github desktop app, this already creates a local repository for me.
Now I have an Eclipse project and a local repository, up to now unrelated. How should I "relate" them?
I found a lot of information about cloning from github, but my github repository does not have a Maven project yet, so I cannot import in Eclipse. If I use command line instead and an empty directory, I cannot apply Maven archetypes any more because the directory is not empty.
I am confused. Can somebody de-confuse me?
Create a new Maven project (however you want to create it). This, of course, will create a new directory in the file system with all the resources.
Create a repository in Github.
From the command line (located inside the project directory) do git init. This will create the local repository inside that directory.
Next, add a remote to your local repository: $ git remote add origin https://github.com/user/repo.git (optionally replace origin for the name your remote repository is going to be called, also replace user for your github username and repo for the name of your github repository name)
Add all files to be commited in the local repository.
For example
$ git add .
# Adds the file to your local repository and stages it for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
Commit changes.
For example:
$ git commit -m "Add existing file"
# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
Push to remote.
Just be clear, taking the following structure as reference, What I propose is to have as git repositories any of the directories project1, project2, projectN, not the whole worspace (/roo_dir/workspace/ directory).
/roo_dir/workspace/
- project1
- project2
- projectN
Additional readings:
Considerations for Git Repositories to be used in Eclipse
Should I store git repository in Home or Eclipse Workspace?
Is it better to keep Git repository inside or outside of Eclipse workspace?
Try this
Create a blank project in git hub
create a maven project in local
clone the git repo
this will not have any file
copy the maven project
add the files to git and push
Finally, I did the following:
I created a new Maven project with an archetype in the directory for github local repositories.
I used the github app to create repository with the same name in the same directory.
Then I published this repository to github.
Now I imported the project from the github local repository to eclipse.
The workflow is generally the one suggested by #lealceldeiro, but without using the command line git.
I am a beginner in maven
so, I am trying to create maven depend on progect in github
I git this project https://github.com/jenshuesken/incubator-olingo-odata4
I need to use ODataJClient, I am trying to git clone and import it in eclipse
but nothing come, please see figure 1
figure 1
I need to use engin in ODataJClient
AM waiting
The right step is build all modules in eclipse,then push it to github. A parent pom includes all modules information. After this,you can git clone it correctly.
I am using eclipse BndTools with a few dedicated workspaces each stored in a single git repo and I've been quite happy sofar.
I've been sharing projects between workspaces by copying them. But recently decided to pull common code into a shared code git repository. In eclipse this is trivial, just use subfolders in your workspace, one per repository.
However to my surprise bndtools demands that I place one cnf project next to my projects in the filebase. At the same time I can only have one cnf project in my workspace. Which effectively means ALL my projects should be peers.
Which in turn means I cannot use multiple git repositories as they cannot share the same directory. Unless I split each project into it's own repository and with 50+ projects this is clearly not where I want to go.
I know eclipse can do this, but is there a way to get bndtools to play ball?
Which effectively means ALL my projects should be peers.
...
Which in turn means I cannot use multiple git repositories as they cannot share the same directory. Unless I split each project into it's own repository
This is where submodule is coming for rescue.
Submodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.
How to use submodules
# Create each project in its own repository
# now add the desired submodule to your project
git submodule add <url>
# now init/update one by one or recursively all at once
git submodule init
git submodule update
I have 3 projects, A->B->C in that dependency order. Currently everytime I make a change to B or C I have to go to the directory and do a mvn clean install in order to install it into the local repository. It is troublesome if I have to do this every time the projects updates.
How can I do it such that every time I do a mvn clean package on A, it will automatically build and install my dependent projects B and C into the local repository?
Create a parent project for all your projects A,B,C and then add all your child project on the parent pom.xml file something like this
<modules>
<module>A</module>
<module>B</module>
<module>C</module>
</modules>
Its called maven multi module project mentioned by #khmarbaise
Here are some example for this
How do I create a multi-module project in Eclipse?
Maven Multi module tutorial
Guide to Working with Multiple Modules
By use of multi module project you will get plenty of benefits like
Anytime you can add any new project with all of the current project
Separation of project is good for code cleanup
You can build Single project or You can build all project in one go.
Duplicacy of jar can be easily ignore .
Maven take care of the build order for you.
One single Jenkins job to build everything.
Plenty of other benefits.But remember if there will some pros then cons also there,its totally now what you want to use .
You can follow the solution I provided to the question Maven 2 Projects, since it is the pattern I usually use when building project with a certain complexity.
Summarizing you would have to create a main Maven project which has three submodules, say master, platform and parent.
The main project has simply the order in which the other projects will be evaluated by Maven
The master pom contains the list of project to be built and their order (aka Reactor order)
The platform pom contains all information about your platform, like JDK version, maven plugin versions, encoding and so on.
The parent pom has the platform pom as a parent and contains all global GAV information about the dependencies you are going to use in your project (Spring, CXF, junit, log4j etc.)
I created a maven archetype which gives me a special folder structure and pom.xml which I often use for my projects in eclipse. Now I created a concrete maven project from the archetype and started working in it. The project is under source control in an external git repository.
How can I check out the project from git (best by using egit) into eclipse AND have my archetype applied to it again?
Currently when I check out the project, I get only the folders which haven't been empty. Any folder that doesn't belong to the standard archetype is not recognized as source folder...
----- EDIT -----
To clarify the question:
I have two options to start with.
Option 1) I could create a new eclipse project from git. The question then is, how do I add the missing pieces from the archetype? Addon question: After creating the project I worked on it and so some changes to the generated files have been made (e.g. example files have been replaced). How do I add the missing pieces from the archetype without overwriting my changes?
Option 2) I could create a new eclipse project from the archetype. A problem is then that I have to enter information that is stored in the pom.xml in git. So lets assume that we know the correct information (artifactId, etc.). How do I connect the newly created project to the git repository and apply the changes from git to the repository? In this order, there should be no overwrite problems.