xcopy a maven .m2\repository\* folder to another computer? - eclipse

I'm using eclipse 3.7 and my local maven repository has a bunch of jars in it. I tried to build the project on another computer that is on a different network and has *.jar download restrictions. I will not be able to get the restrictions lifted. Here is an example error:
e.g. Access denied to http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar Error code 403, Forbidden (Content blocked ...)
It would be very nice if I could simply copy my .m2\repository\ folder into the .m2\repository\ on the other computer--both are running windows. I really don't want to manually install 100s of jars on the other computer.
Is xcopy for .m2\repository\ supported?

Yes, you can copy the .m2/repository folder to any other location/storage device you want.
Maven only needs to know the path to the local repository (by default it's in %USER_HOME%/.m2/repository). You can change that path in Maven's settings.xml (see settings reference) if you decide to keep the artifacts in a different location.

Related

Does the buildpath needs to reconfigured on local machine for a project checked-out through SVN?

This is my first time using SVN or for that matter any version control. So, I've been able to check out a selenium project on my local machine. This source code was working fine on the other machine(my friend's), but on my machine it throws hundreds of errors such as "BeforeClass cannot be resolved to a type, Assert cannot be resolved to a type" etc.
I do know that this error could be because the required selenium jars may not have been setup in the build path. But, I can see all these selenium jars in the "lib" folder.
So, I want to understand if I need to reconfigure the build path. By the way, don't the project settings etc come by default as the same code works perfectly on other machine, which means the build path must have been configured there.
I know its a very basic question, but I assure you that I'm a naive coder.
Thanks for your help.
Note: I'm using Eclipse IDE
Eclipse's project configuration files (eg, .project, .classpath, .settings, etc) are designed to be checked in with the rest of the project. If done so, whenever the project is checked out to a workspace Eclipse will automatically use them to properly configure the project. Check that your friend checked in those files; if not, ask him to.
It looks like you did not add Eclipse project metadata files(.project,.classpath) & .settings folder to your source control system, so Eclipse doesn't know what your build path is or whether it is even a java project.
Go back to your other computer and look for the following files in your original project root...
.project
.classpath
.settings/*
Make sure all are present in Source Control System.

Scala IDE and classpath

I have a Scala project I share via git between two (windows) machines. I have them set up using SBT and sbt-eclipse so I can edit and test within eclipse or build and test from the command-line.
Unfortunately my user name (and, therefore, the user profile directory) is different on the different machines. This means that when sbt fetches dependencies it puts them in different base directories on the two platforms. This wouldn't be a problem except that the full pathname is hardcoded into the eclipse .classpath file from sbt-eclipse. This means that I have to rerun the 'eclipse' task when I do a pull on my 'current' machine.
This must be even worse for others who do this kind of thing as a team. How is this normally handled? I would prefer to do a pull on whatever machine, even from within eclipse, and get started right away.
I would strongly recommend removing the eclipse-sbt-generated files (and all other generated files) from git. Each machine will have it's own .classpath file that is generated on that machine that is generated on that machine for that machine and can be regenerated whenever you want/need. Your build.sbt project files should be in git, so when you pull onto each machine, it will have the updated config, and you can just run sbt eclipse only when you have a dependency change.
Really, you should always avoid having generated files in source control. Have only the important stuff in your git project, and generate the rest as necessary.

Remote Play framework and Eclipse

I have a play framework project which run on remote server.
I'm trying to configure eclipse to work remotely on the project.
since no build is required my requirements are to be able to edit the project files from eclipse and automatically save on server, auto complete and debug.
I've installed Remote System Explorer on eclipse and setup a remote ftp connection to my server.
The play environment on my server is under
/play-2.0.2/
My project path is
/play-2.0.2/test
In RSE I clicked on /play-2.0.2/test and 'Create Remote Project'
Now in Java perspective I can browse through the project, change files and then automatically save to server.
My problem is auto completion of play framework library doesn't work well since all the reference are to /play-2.0.2/repository/...
any idea how to solve it? I tried to play with the build path but no success
Thanks!
So, I was looking into achieving the same thing myself.
The problem you are experiencing is due to the fact that the .classpath file has absolute values. While for me, besides the symlink that doesn't work between two different kinds of O.S., I thought on another two solutions:
Use sed to rewrite the classpath on the .classpath file after it's generated
Use a "classpathTransformerFactory" for the sbt eclipse command
I haven't had to deal with it (it's more of want to than whatnot) as soon as I do, I will explore the two options and post details. I just leave the answer here in case someone wants to pick up where you left.
Another thing is:
Seen that sbt picks up the libs referenced in build.sbt, downloads the jars and puts them in the ~/.ivy2 directory, if you use any of those methods to change the reference from the remote machine to the local one, you would need to make sure that the same libs are on the local ivy cache. So, just as I wrote this, another idea came to mind:
sbt eclipse or play eclipse or activator eclipse [it should be the same] on a local environment, and on the remote one, then, transfer the .project and .classpath files from the local to the remote, and see what happens (if it doesn't work, scan them for absolute and incorrect paths that might need to be changed)
Sorry for the unproved answer, still I think it's better than no answer.
Cheers

What is different in different user accounts when doing a maven build

I've been trying to do a maven build of this project. It downloads a lot of artifacts from a repository and builds fine on one account (local account). However, when i log into a network account(same computer) with the same eclipse/maven installation, same workspace, same environment variables(I only have 2 user ones), it fails because it tries to read from a different directory that doesn't exist (C:/schema/blah/blah/blah) when it should be reading from (C:/workspace/Echo/target/main/xsd/blah/blah/blah)
Is there something inside eclipse or maven that stores local users settings i could look into. The code for this project would be nearly impossible to post since it has ~30 jar files. I'm at a loss.
Thank you in advance to anyone who has ideas or suggestions
~Ryan
check the .m2/settings.xml file in both user home directories. You may want to set the <localRepository> to the same (shared) location so it does not download the same artifacts from remote repositories twice.

eclipse projects and compiled data

in my Java Eclipse project that contains JUnit tests, I also have a package "resource" that contains all input data used for the tests. But when compiling JUnit tests, the Java compile also data available in resources, so I find the same data in the "bin" folder. Is there a way to avoid this?
thanks.
If you have a particular package within the source path you want to exclude (your resources folder for example), you can right click on the package and select: Build Path > Exclude.
This will tell Eclipse that you don't want to include that package as part of the build.
This is making a couple of assumptions: that you're using Eclipse Helios (because the option might be different in older versions), and that the resources are stored in the same folder as your regular java source files (because if resources is in a folder by itself, you can remove that entire folder from the build by using Build Path > Configure Build Path -> Source tab.
Update:
After the discussion in the comments regarding why you would or would not want to copy resources into the bin directory:
The contents of your bin directory should be ignored and not checked into to a version control system (when using CVS, bin should be an entry in the .cvsignore file)
The resources are only duplicated on your local machine, which is fast and hard discs are big. I'm not sure you should be worrying about this
If you're using Class.getResource to access those resources, they need to be on the classpath somewhere. The bin directory is as good a place as any
So, realistically (barring some unknown, like the files are hundreds of gigabytes or something), I don't think you need to be concerned about excluding these files from the build.