Which are the files that I have to ignore when adding a project to git?
Should I add the .classpath file?
What is the purpose of .classpath?
Im using eclipse and pushing to a Jenkins server
Typical gitignore file for android would include this:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
From Gitignore on github
While creating a project in Eclipse, by default it creates a .classpath file in the project directory. That file will be used for storing file names and other dependent files needed in the classpath to compile and execute the project successfully. Normally this file will be updated automatically when ever you update the project libraries etc.
You should add it to git in my opinion. See this thread for more:
.classpath and .project - check into version control or not?
Related
I am trying to add external jars to my Java (without Maven) Project.
But I don't get it to work at all.
The official documentation: https://code.visualstudio.com/docs/java/java-project
says there are 2 ways to do it:
1."You can use the Java Dependency Viewer to add any JAR file to your project."
https://code.visualstudio.com/assets/docs/java/java-project/manage-dependencies.gif
As you can seee in the gif, the dev opens a "referenced libraries" folder.
This folder DOES NOT EXIST for me.
or 2."The other easy way to bring additional JAR files as dependencies is to create a lib/ folder in the root directory of the standalone files and place your JAR files there. Source for foo.jar is automatically detected if there is a foo-sources.jar in the lib/ folder."
https://code.visualstudio.com/docs/java/java-project/lib.mp4
I have the Jar file in the lib\ folder but it still shows me he same error messages.
Are there any steps I am missing?
As it says, place the external jar files in the ...\JAVArpg\lib folder.
So copy them from wherever you have them now. cp ../lib/*.jar lib/ is just an example.
You can use the Windows Explorer. You don't have to copy the files using a command-line.
I am new to project environment setup. Below is my project structure in eclipse
Project Name
--> .settings
--> .bin
--> lib
--> resources
--> src
--> .classpath
--> .project
I am attempting to export src folder as jar.
When i export to jar, all the above folders & files are created in jar. But i need to convert only src folder as.
Also when i export to executable jar, all the third party libraries are exported as class files in jar. is it right.
What is the best practice to export project. Only src folder or everything.
Which i need to use jar/runnable jar. My requirement is to write start/stop bat file to call jar and execute java program.
Please advice me. Thanks in advance.
First it's important to know what these folders actually do. Following are the workings of several of these files.
.settings -> This file records project specific settings and workspace preferences.
.bin -> folder is usually where the compiled files are copied to.
lib -> contains external libraries that are used in your project (like Apache Commons)
resources -> the resources like images, text, pdf, audio, video are usually copied here
src -> the folder where the project's source files are located.
.classpath -> It contains information that the JDT feature needs in order to properly compile the project: the project's source folders, the output folders , and classpath entries.
.project -> This file is maintained by the core Eclipse platform, and its goal is to describe the project from a generic, plugin-independent Eclipse view.
So you can see that if you exclude some of the files like lib, resources, bin etc... Your jar file will probably stop working. Your jar file needs compiled files and their dependencies.
For example: All your compiled .class files are in bin folder. And your jar works because of these .class files and NOT .java files that are in src. If you delete this bin folder then your jar will probably stop working.
Also, your project may be using some external library supplied by someone else. Like Apache Commons or google/guava and these are usually in lib folder. So you can't delete this folder as well.
However, if you no longer expect to use .java code, then you can exclude files that were created by eclipse to manage this project. See this post.
see also:
1. What's in an Eclipse .classpath/.project file?
2. exclude files from jar or war in eclipse
Android Studio recommends using the gradle wrapper in the build work flow. However, if you are using git for version control, .jar files are ignored and are said not to be checked in, which I get. But my workflow is a little different than the average person. We are also using Team Foundation Server and git both. The gradle build gets called using a custom MSBuildTask. Here is what my .gitignore file looks like:
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
The way it currently works is first we pull both from TFS and our git repo into a common location, then we merge the two, check the result back into TFS and push the result back to the git repo. After this is complete, the custom MSBuildTask is executed which basically just calls "gradlew build". However, this fails because the gradle-wrapper.jar file isn't being pushed to git, its being ignored. Any ideas on how to accomplish this? Thanks in advanced!
As Peter mentioned, jars are not ignored due to your .gitignore file; I guess the jars are ignored due to a .gitignore file located in a parent directory of your project directory. Can that be the case ?
Anyhow, if that is the case, you can try using a negation in your .gitignore file, something like:
!**/*.jar
In that way, you override rules from a .gitignore file in one of the parent dirs.
I have a Java project that I'm working on in Eclipse. I have all my code in a src. Eclipse automatically compiles my .java files and stores the .class files in a directory called tmp.
Earlier, I was suing Ant to run my project. My ant script would would compile my Java code, and Jar all the .class files into a .jar and store it into a jar directory. In this jar directory I have some other files e.g. settings.cfg and data.lst. My application needs these files to run but they should not be included in the Jar. They will be deployed along with my JAR and should reside in the same directory. Currently while developing, I have modified and customised my settings and properties files to contain additional information. I don't want these files replaced every time I have a new build as I would like the data to persist across builds. I'm just looking to get the built JAR into the jar directory and execute that. The rest of the files stay the same.
How can I configure my Eclipse so that it always compiles my code, JARs it to the jar directory and executes that JAR. That way, my "extra files" are always in the same place as the JAR.
I'm having a lot of trouble figuring out how to accomplish this.
If you need this feature for fast running/debuging, create new Run Configuration and in the Arguments tab, Working Directory specify the "jar" directory.
The answer was found on another SO post. It was about creating a new "Run Configuration", removing the default classpath entries and adding a the folder containing the JAR i.e. the jar directory and also the JAR file itself.
Here: https://stackoverflow.com/a/1732316/304151
I also had to modify the build configuration a bit. For automatic builds, it used the Java Builder to compile all the .java files into .class files and store it in the tmp directory. I used a custom Ant task to package all the .class files from the tmp directory into a JAR and store it in the jar directory. This is the file that Eclipse executes.
In your project, right click Properties, in "Java build path" menu you can set "default output directory" in the Source tab and make it point to jar directory:
Just put an Android project under git (beanstalk) version control via the command line (mac terminal). Next step is to set up exclusions.
To those of you who have already been down this path:
What should a typical .gitignore file look like for an android project?
Project set up in Eclipse
You can mix Android.gitignore:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
with Eclipse.gitignore:
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
In addition to what the others have suggested, I'd like to add the proguard folder, in case you are using it. You can either ignore the whole folder or just dump.txt, seeds.txt and usage.txt. Basically, it's a good idea to keep mapping.txt versioned, so that you can debug obfuscated stack traces from your users. More details here.
This is my standard Android .gitignore and .hgignore file. It usually works pretty well.
bin
gen
target
.settings
.classpath
.project
*.keystore
*.swp
*.orig
*.log
*.properties
seed.txt
map.txt
It has eclipse, vim .swp files, mavens target folder and files for proguard mapping included.
Update: I have put my .gitignore for Android development online.
Well I know that the github/gitignore repository on GitHub has an android .gitignore file. This might be what you want as it should be very general for android development.
The actual content of the mentioned file:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
Here is the one I use in my Android projects, it supports both ADT and Android Studio, so it is good if you are working with a team.
# General Folders
# gradle/ comment this when using gradle wrapper.
build/
bin/
gen/
tmp/
# proguard/ comment if not using proguard.
.gradle/
.settings/
.idea/
# General Files
.project
.classpath
.DS_Store
local.properties
*.iml
# gradlew comment when using gradle wrapper
# gradlew.bat comment when using gradle wrapper
Thumbs.db
# files specific to current project
your_apk.apk
Simply github can generate .gitignore for Android projects repositories
And its content will be like the following
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
In Addition, if you use IDEA's IntelliJ, and you build Artifacts (and you should), then you might want to add:
out/
(that's where Artifacts are built by default).
And if you don't want to share your IntelliJ project stuff ignore
.idea/
In my project root I have a file .gitignore. It contains:
/bin/
/gen/