Ignore Mercurial sub directories - java

I have a directory with my Maven projects in it. It looks like this:
.hg
.idea
parentProject
project1
.idea
docs
src
target
pom.xml
project2
.idea
docs
src
target
pom.xml
target
pom.xml
.hgignore
I want to ignore the .idea and target directories in all my project. I have included the .idea and target directories into .hgignore but it only ignores those directories in the which .hgignore file is. This means that only in root directory .idea and target is ignored.
If I add .hgignore file in all sub projects this does not changes anything files are still not ignored.
My ignore list looks like this:
build
dist
target
faces-config.NavData
.idea
.iml
How should I specify in the .hgignore to get the .idea and target ignored from everywhere?

try hgignore with regex
syntax: regexp
^\.idea$
^target$

How about something like **/.idea and **/target? Check out the possible patterns here.

You should not need to explicitly ignore target directory.
This problem will come if you have added it by mistake to Mercurial. Let's say you have done the following:
Created a project and compiled a few times (hence target directory
exist)
Decided to add source control to the project so you've
initialized a Mercurial repository and executed hg add command
(either implicitly or explicitly from the IDE). Bam! You have now
told Mercurial that target is a directory that should be included.
Trust me. I've been there !
To fix: Do the following from the command line:
hg forget target
When it comes to .idea directory I would think there's no other way than to use the .hgignore file but I'm puzzled why Intellij IDE doesn't add this automatically. (not a Intellij IDE user myself). That is the real question to ask.

Related

Gradle War Plugin: creates an intermediate directory in project root

I have a Gradle project, which produces a .war file at the end of the build. It works great, except for one thing.
While building, the plugin creates a directory in the project root folder called war, which contains basically the exploded version of the end result.
I wouldn't be bothered by it, if it wasn't in my build directory, because this way, it looks awful and also, IntelliJ picks it up as a Web root, which is annoying.
In the documentation I think I found the output property, which seems like the one telling me where this folder is. The problem is that it's read-only, so I can't rewrite it to my liking.
Is there a way to put this directory elsewhere?
Here is a link to my build.gradle file
It turns out, that I falsely accused the Gradle War Plugin with creating that folder. In fact, it was the Gradle Gwt plugin

Cant add target folder to .gitignore

I have Spring module project on Bitbucket with 2 Spring Boot apps in it. In the root module I have the .gitignore file and in every app I have .gitignore file with this content :
config.properties
.classpath
.project
.settings/
.idea/
target/
*.iml
I tried pulling project again but no changes.
Config.properties do get ignored but target folder isn't. Every time I make some change, I get target folder file in my git changes list.
There are a couple possibilities that come to mind.
Ensure that you haven't yet committed the target/ folder. This would prevent the gitignore from doing its job and ignoring the added folder.
The other thought is you have a multi-module project. Ensure you are calling the correct target/ folder to ignore: How to .gitignore files recursively
The new patterns in the gitignore donĀ“t work for existing directories.
Make sure to remove the existing entries in the git for the target folders:
git rm -r --cached etplans-web/target
Make sure that your "target/" folder path is correct. Look for examples here
i think its because you've accidentally added a file in target directory and so git doesn't ignore it.
hope this would help

Manipulate the java class path of an Eclipse plugin?

I am working on a plugin that consist of a homemade view to Eclipse.
When I run the plugin and display the classpath using System.getProperty("java.class.path")
I get this as output : D:\Programs\eclipse\plugins\org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar
I would like to add some .jar files for the proper functioning of my view, but I can't figure out how... I guess you can do it by adding some specifications to the MANIFEST.MF of the plugin but I don't know how to do it propely.
any ideas ?
Each Eclipse plugin has its own classpath. To use additional jars in the plugin you need to include them in the plugin.
Add your jars to the plugin directory. Usually they are put in a 'lib' directory.
Open the plugin MANIFEST.MF editor and on the 'Runtime' tab in the 'Classpath' section click the 'Add...' button and add your jars to the class path.
On the 'Build' tab of the editor make sure the 'lib' folder is include in the Binary Build section.
Your MANIFEST.MF should end up with a `Bundle-Classpath' entry that looks something like:
Bundle-ClassPath: .,
lib/jogg-0.0.7.jar,
lib/jorbis-0.0.15.jar,
lib/vorbisspi1.0.2.jar
(here I have 3 jars in a lib folder).
The build.properties file should be something like:
bin.includes = META-INF/,\
.,\
plugin.xml,\
lib/,\
lib/jogg-0.0.7.jar,\
lib/jorbis-0.0.15.jar,\
lib/vorbisspi1.0.2.jar
For Compile time we need to add it to the Project runtime library.
For the run time you have to package the jar either in your EAR/WAR file or Load it to the Application server as a App server libraries.
Please let me know if you need further assistance on this.
The best approach I've found is to create a lib directory in your Eclipse project (where your view is contained). Place your .jar files in said lib directory.
Then using the editor on the MANIFEST.MF, you add the .jar files to the classpath. If you wish to export the packages, you then add to the Exported Packages as well.
Depending upon what you are doing, you may wish/need to also update the Build Configuration.
If you examine the MANIFEST.MF file itself, you will then see an entry for Bundle-ClassPath. It will list your entries. Here it has the standard "." for the project, a resources/ directory that we export, and a couple of .jar files.
Bundle-ClassPath: .,
resources/,
lib/aopalliance-1.0.jar,
lib/apccore-client-2.11.8.jar,
lib/cglib-nodep-2.2.2.jar,
lib/ehcache-2.10.3.jar,
...
Note that in our experience, it is also necessary to adjust the Java Build Path from the Properties of the project itself. A user commented that this step may not be necessary. We are on an older version of Eclipse due to our product, so YMMV, If needed (usually compile failures are the indicator), you then need to add, via the properties context menu on the project, the .jar files to the "Java Build Path" (you can do the same with a resources directory).
This will allow you to properly build using the .jar files.

Indecision on which files to upload on GitHub

I have a java project made with Eclipse.
While working on a project, Eclipse creates a bunch of files and folders, what folder and files should I upload on GitHub?
I think that everything under the src folder should be uploaded. Am I right? Should I commit the .java or the .class files?
source control such as git are used to commit anything that can be called as source and not environment specific. So code, related resources should go but any IDE specific files.
Use gitignore either project specific or globally. The easiest way is to create a .gitignore file in your project root repository. For instance
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
out/
artifacts/
# Mac
.DS_Store
# Maven
log/
target/
It depends on which files do you want to share too.
For example, in my current company almost all my colleagues and I use Eclipse, so we have repositoried .project" and .classpath too. It is very handy because changes in .classpath are done only once, and then propagated to all developers.
If your root folder is both the git repo root and your workspace, you won't probably want to upload the .metadata folder, since it contains settings specific to each different developer. And, by all means, you will want to ignore Eclipse's compiled directory (typically /bin).
Think about what do you want to share and/or version, and that will probably give you a list of things to upload/ignore.
Edit: as said before, upload ONLY .java files, .class files are products of your source code, and have to be generated, not stored.

Should Eclipse-specific files in an VCS be ignored, if using Maven?

I know why not to commit Eclipse/IDE-specific files into a VCS like Git (which I am actually using). That is one of the reasons I am using Maven and having it generating these files for you and not having them under version control.
But I wonder, if these files should be ignored in .gitignore which itself is under control of VCS/Git:
.classpath
.project
.settings/
target/
Is this okay?
What are the pros and cons since the .gitignore file itself becomes kind of IDE-specific as the files ignored there are IDE-spefific? Any best-practice?
With the team's I've worked on, the general rule has been that you don't check in anything that is generated by or obtained by Maven. Since the pom.xml contains everything you need to create the .project, .classpath, and .settings files, we don't check them in.
My .gitignore always contains .classpath, .settings, .project, and target for Maven projects.
Edit: As mentioned in my comment below, here is another suggestion: If you really want to avoid having Maven or IDE specific entries in your .gitignore, try writing your .gitignore so you list only what you DO want checked in.
*
!stuffIDoWantToCheckIn
I'm getting my information from the following article: https://help.github.com/articles/ignoring-files
That suggests that you can create a global gitignore file (suggest under ~/.gitignore_global) containing .project, etc. As the file is outside the repo, it won't show...
You register it as a global ignore file with the following command:
git config --global core.excludesfile ~/.gitignore_global
Alternatively, you can create a per-repo untracked gitignore entries in the .git/info/exlude file
I agree on not putting the IDE files under version control, this occasionally causes all sorts of pains, and as you mentioned using maven renders this unnecessary as any developer can simply import the project from the POM and get going
If these files are not put in the .gitignore they can easy be checked in by mistake
furthermore I do not find listing them in the .gitignore makes it IDE specific, you can list project files of eclipse, IntelliJ IDEA, and Netbeans, all in the same .gitignore if your team members use a mix of different IDEs. Over time you may accumulate a template .gitignore that ignores project files from all IDEs used in your team(s) to use whenever you create a new repository
If you are totally against putting these in the project .gitignore you can put them in the users .gitignore, but that in my mind is a bit looser as it depends on the individual development machines being configured correctly, and also these need to be maintained to be kept in sync with any new additions
Edit: I currently have an equivalent .hgignore, same concept different syntax, I converted it to git as an example of such a .gitignore file
/target/
/bin/
/build/
/.classpath
/.project
/.settings/
/.checkstyle
/atlassian-ide-plugin.xml
/.idea/
/*.iml
/*.ipr
/*.iws
*.orig
*.swp
*~
usually .project and .settings/ should likley be versioned and ignored!
.classpath and target should not be versioned but ignored.
This is a first inital boot-up on checkout-practice.
i.e.
You told everone to use four spaces as tab, this information is stored under .settings/xxx
but you give no restriction where they have to install their tomcat/jdk's (stored under .classpath)
ok?

Categories

Resources