Possible to execute Java Maven Project in MS TFS?
I have linked the project inside MS TFS using the POM file but it dosnt seem to open any browser(s) instances.
My POM file has a surefire pluging used to execute the TestNG xml but that dosnt seem to work,
The tests run too quickly and the results are inconsitent, is this even possible?
Thanks for your help
Use your build server to make life easier. The easiest way to create a build definition for a Maven build is to use Eclipse with the TFS plugin. You connect to your project, create a new build definition, choose Maven, and it will construct a TFSBuild.proj file (yes, the really old Upgrade Template). At the very bottom of that tfsbuild.proj file, you'll need to edit to look something like this:
Note the "Goals" entry - this can be modified to your specific goal.
In the build definition, the Configuration Folder Path will have the value of the location of your TFSBuild.Proj file - just the folder. By default, it will be created in $/YourProject/TeamBuildTypes/YourBuildName. In Source Settings, the location of the POM file is mapped to $(SourceDir).
If you are using the TFS2015 or later with vNext build system, you can refer to this link for detailed steps: Build your Java app with Maven.
Related
My goal is to run unit tests in fitnesse.responders.run.slimResponder for testing my DataFlex SlimRunner implementation. So I downloaded the Fitnesse source code, and made it a new Java project in Eclipse. I was able to compile it by selecting Run As Ant Build (2) on the build.xml file. But in order to resolve include errors in the Problems view in Eclipse, I ended up manually adding dozens of external JARs by hand. I found that Maven/Ivy had apparently downloaded the jars as part of the Ant build. But somehow these were not added to the Java Build Path.
It seems reasonable to me to assume that there should be an easier way to set up the Java Build Path than to add the JAR files manually, since build.xml apparently contains all this information already. What am I missing?
The Fitnesse Readme.md mentions using Apache Ivy for dependency management. Download IvyDE from Eclipse Marketplace, and set it up (use the ivy.xml that is part of the Fitnesse source code).
I am using the Java Marine API found here: https://github.com/ktuukkan/marine-api but the jar they provide on their download page is not suitable for my project as it misses the the ability to read one of the sentence types i am using (the task involves GPS Sentences from a receiver).
The question i have is, i have cloned the Java code from this github repository how i will now edit this, it has a build.xml so how can i convert this code into a .jar so i can attach it to my project as an external library.
Thanks,
Chris.
It has also pom.xml present in the root directory. It means it uses Maven tool for building. You should find the jar file in the resulting target directory after running
mvn install
For skipping the test suite you can run
mvn -DskipTests install
However, according to javadocs this library allows you to add your own parsers at runtime too, so you don't actually need to build it.
It is the following situation:
I currently have multiple Java projects in Eclipse. All the sources, build files etc are checked in at a repository. If a new team member joins the project he has to rebuild the complete setup (setting build path dependencies, adding special libraries).
I thought if that could be automatically done some way, e.g. using an ant file to do all the configurations of eclipse or the servers (tomcat).
Anyone ever found a solution for this?
Check in the .classpath and .project files and you should be set!
(More information about the .project file.)
I believe that you might use Maven too.
But that would require quite an adjustment, I believe.
I'm working on a swing project, using maven2 (from command-line) and eclipse (without maven integration). So, I generate the eclipse project through maven eclipse plugin (mvn eclipse:eclipse), import it inside eclipse, and do all my work.
My problem is: when I run my app in eclipse (as a Java Application), I can't find none of the resources that are in my src directory. Digging for information on my problem, I get into this answer from another question. So, I compared the output from the following instructions:
MyClass.class.getResource("/").getPath();
MyClass.class.getProtectionDomain().getCodeSource().getLocation().toString();
Those gave me the following outputs, respectively:
${workspace_loc}/${my_project}/target/test-classes/
file:/${workspace_loc}/${my_project}/target/classes/
Checking the above locations, I could see that the former is empty, while the other one contained all my compiled classes and resources. So, I came to the conclusion that the classloader is looking for my resources in the wrong place. So, I think I have three questions:
Is my understanding correct?
If so, how it does to find the classes it is loading?
How do I solve this?
UPDATE: I've changed my code, so instead of invoking MyClass.class.getResource(...) or MyClass.class.getResourceAsStream(...), I'm now using ClassLoader.getSystemResource(...) and ClassLoader.getSystemResourceAsStream(...). In this way, everything is working fine in eclipse. I just don't know exactly why. Any hint on this?
Two possibles cases for me :
You are using eclipse to compile your project. Then eclipse is configured to exclude (or not include) resources in the src folder. You can set it in Project/Properties/Java Build Path/Source. Then you expend your src folder, and ensure you have something like "Included All", "Excluded None".
You run your maven application using maven to compile and not eclipse, even though you are using eclipse as your IDE. Then by default maven will not copy resources from the source folder to the output folder... Because it is not the standard maven way of doing things. Thus the resource are missing from the classpath and you don't find them. Just change your maven configuration to also include resources from your source folder.
I think you have to add src/main/resources to the build path. This is done in Project Properties > Build Path > Source. Here is how the standard maven project looks:
In future when using Eclipse I suggest to use m2eclipse plugin and create project using it. This will automatically make sure that all these folders are in the build path.
Try this:
Run configurations... -> Classpath -> User Entries -> Advanced... -> Add Folders
Can you try loading the resources using below?
this.getClass().getClassLoader().getResourceAsStream(propertyFileName)
This might be useful information
Eclipse Maven plugin has its own Classpath Container that conflicts with generated class paths when enabled.
What I would suggest is stop using eclipse:eclipse (sorry - harsh I know). I used it for about 8 months, cant believe it took me that long, and used M2Eclipse. M2Eclipse is an eclipse plugin in which you do the following.
Enable Dependency Management.
Update Project Configuration
(In Eclipse) Project -> Build Project
(In Eclipse) Run Application
It may not seem it, but its a much easier and less frustrating way of doing it.
Before, with eclipse:eclipse. You would have to run it then hit refresh and hope that everything is configured - if you have a multi-module pom things can really go wrong.
For me the Files within the WEB-INF were not getting included. Hence I added them to Buildpath (Project -> Build Path -> Configure Build Path -> Add folder (project/src/main/webapp). This resolved the issue.
I have a series of Eclipse projects containing a number of plugins and features that are checked into CVS. I now need to run an automated build of these plugins. Ideally I'd like to do it without having to hardcode large numbers of Eclipse library locations by hand, which has been the problem with the automatically generated Ant files that Eclipse provides. The build also needs to run headlessly.
Does anyone have experience of this sort of set-up with Eclipse, and recommendations for how to achieve it?
There are a few options for you to look at, depending on which build scripting language you're using:
For Maven2, the way forward seems to be Spring Dynamic Modules. Other options are Pax Construct, m2eclipse, Maven BND
For Ant/Gant, Eclipse PDE Build, Ant4Eclipse
For command line or both the above, Buckminster.
At my current clients we use Buckminster, which wraps PDE-Build, and call it from Ant/CruiseControl. We've got code coming in from multiple repositories all being built into a single RCP product.
Also, these questions may be of help.
The standard way to make an Eclipse Build is to use the PDE Build Plugin.
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tasks/pde_feature_build.htm
http://wiki.eclipse.org/index.php/PDEBuild
The PDU plugin is normally included with the Eclipse IDE and contains a series of templates. The templates help you set up a system that will:
fetch: Checkout all plugins and features using a map file, that contains the locations of the plugins
generate: Creates a build process for every plugin checked out
process: Compiles the plugins
assamble: Jars and packs the plugins
postBuild: Allows to set up automatic tests and deployment
Theoretically all you need to do is to modify a customTargets.xml file , write a map file that contains a reference to every plugin that you need to check out and modify a build.properties file to indicate such properties as the cvs server location.
I had a similar problem to the one you have. The build mechanism is divided into several steps. You can customize the preFetch target of the customTargets.xml file so some "bulk" libraries are imported from specific trees in the repository and add them to the build directory, so you don't have to specify every single plugin in the map.
You can use Tycho to build your eclipse plugins with Maven. This is how the M2eclipse plugin is built. Find out more at http://m2eclipse.sonatype.org
You could write some sort of a script that finds those libraries for you and puts them into a format understandable by Ant.
For example, it could build a eclipse.lirbaries.properties file, then you could read in that file using:
<property file="eclipse.libraries.properties" />
You could also use the FileSet attribute:
http://ant.apache.org/manual/Types/fileset.html
Or even a combination of both.
1) Call Ant Script
2) Ant Script calls bash (or whatever scripting language) script which builds eclipse.libraries.properties
3) Ant loads eclipse.libraries.properties
4) Ant goes on with the build