We have recently switched to TeamCity 7.1.4 for our automated build system and attempting to add ChargifyNET dependency to an existing project. I have read up on the Build Artifact concept and the Dependent Build concept and they both seem pretty straight forward. However, the documentation really isn't clear on how to add a dependency that you do not need to build/compile.
Ideally, I would like to store the archive containing the ChargifyNET binaries in a folder and be able to reference that archive as an artifact when configuring dependencies for my project. How can I set this up?
So far, I've configured a separate project for ChargifyNET and declared the individual binaries from the archive as artifacts for this project (for example, %teamcity.agent.work.dir%/Chargify.NET/1.0.7/ChargifyNET.dll). Then I added a dependency to the main project for the ChargifyNET project artifacts.
When I build the main project I get a "Artifacts resolving failed" error. In the build log, under "Resolving artifact dependencies" I see no mention of the ChargifyNET artifacts.
How can I add ChargifyNET as a dependency to a TeamCity project? Do I need to get into a custom Ant script or can this be done from the UI?
Maybe the issue is with the artifact paths. Should 3rd party libraries be stored under the agent work directory or some other folder?
Is it best practice to have all 3rd party libraries checked in to a VCS repository? Perhaps a different solution would be to add an additional VCS root to the main project that points to the VCS repository holding 3rd party libraries.
Creating the Chargify.NET project as mentioned in the question was on track.
Create a build configuration under this project and enter a static build number (i.e. 1.0.7).
You have to "Run" the Chargify.NET build so TeamCity will create a dynamic build folder for it in the agent work directory.
Copy the Chargify.NET binaries into the folder created in step#2.
Modify the artifact path(s) from "%teamcity.agent.work.dir%/Chargify.NET/1.0.7/ChargifyNET.dll" to just "ChargifyNET.dll". This new path should refer directly to the files mentioned in step#3.
Modify the artifact path(s) in the Build Dependencies section of the main project to for Chargify.NET. They should look the same as in step#4 except that you may want to add a destination path (like so "ChargifyNET.dll=>trunk/bin").
Build the main project and you should see the files importing correctly.
Related
I have a workflow working on an application and one of its libraries that somewhat looks like this:
Make changes to library -> Push library jar to remote Maven repository with no version change -> Pull updated library jar from the remote repo to the downstream app -> Test and make changes to the app and library
But seems like the way IntelliJ indexes and/or caches Maven dependencies is not affected by me running a clean install from the Maven interface. Is there a surefire way to force IntelliJ to discard any cached dependency and reimport, or possibly do it only for a desired library?
Very likely this has nothing to do with IntelliJ. Since the version number is the same, maven won't re-download your dependency. Try to just delete the dependency locally from the maven repository:
rm -rf ~/.m2/repository/<..path to your library package..>
You could also avoid pushing the library to the remote repository, and test completely locally, by using the library as a local dependency. For this approach, see answers here: How to add local jar files to a Maven project?
Or since you are not effectively changes the library version the right approach would be to use the library project sources as a direct dependency for IDE maven project. For this - add this Maven library project as a new module to existing Maven project: File | New... | Module from Existing Sources... and select pom.xml file of this library project.
Are there any plugins or ways to download the dependencies for a maven project from Jenkins? I am using Jenkins for a multi-module desktop application. Although I know I could just archive all dependencies, I don't see why there isn't the ability to download dependencies using maven which installed on the same machine as Jenkins. Preferably one would specify the location of a pom and then have the ability with one click to download all the dependencies for that pom. Can you do this? I do not need or want an entire binary repository for this feature.
Edit: I will try and rephrase this as I don't think people are understanding.
In Jenkins one has the ability to archive artifacts at the end of a build. Also in jenkins you have integration with maven. When building a jar in maven you have arguablly 2 options:
You can either use the assembly plugin which zips all .class files
together with those produced from your source code resulting in 1 jar
You can create a jar just source code which references all
dependency jars which are located in a separate folder.
In Jenkins one also has the ability to download the latest artifact. Now if I am using Option 2, I can either archieve just the jar which my sources produced, which I would say is more desirable for space and is the whole purpose of the archive functionality, or you can also archive the libraries too.
Here is the PROBLEM!! If I don't archive the libraries then I cannot easily run this jar, as it is a desktop application and its dependencies cannot be obtained in the same mannor as clicking on a link from jenkins. So lets say my question is what is the easiest way to obtain them? Extra info: assume jenkins is running as a server and you can't use artifactory or another server application, that seems to me to be massive over kill.
Use the maven plugin and create a maven job for your project. Jenkins will then use the maven command you provide in the job configuration to build the project. This means maven will download the projects dependencies and store them on the machine jenkins is running. Normally this would be <JENKINS_HOME>/.m2/repository. This way you get a local repository that only contains the dependencies of the projects you created maven jobs for.
Currently I'm working on integrating grunt build process to our maven build process.
Here are two options I can think of:
Pointing some folder in resources as a target build dir for grunt project.
Building grunt project wherever and enlisting this this non-standard folders as included resources in the pom.xml.
It looks like there is yet some space to enhancement. Basically, since grunt subproject
does not depend on any external resources, it would be nice to learn how not to rebuild war-file that had been already compiled, but modify it after rebuilding grunt-project.
So, the question is:
What are the best practices adding generated resources to an existing war file.
The approach of adding resources to a war file amounts to modifying a maven-built artifact after maven builds it. That runs counter to the maven philosophy of tightly controlling the entire build of every artifact. You really have three choices:
Include the grunt generated source in the war's source and build a single artifact with maven. In this case you rebuild the war every time grunt resources change, or
Put the grunt generated sources in a second maven artifact and make that artifact a dependency of the war artifact. Maven will still rebuild the war every time, but you get the separation of builds you seem to be implying in your question, or
Make the dependency in (2) a runtime dependency, if possible. You basically make the scope of the grunt artifact dependency "provided" so you don't have to rebuild the war every time your grunt artifacts change. You only have to rebuild your grunt artifact.
It sounds like you want to go with option (3).
A war file is just a zip file with a certain file layout, you could just add to the archive using a zip tool. For example my linux platform zip command has the -g command.
-g
--grow Grow (append to) the specified zip archive, instead of creating a new one. If this operation fails, zip attempts to restore the
archive to its original state. If the restoration fails, the archive
might become corrupted. This option is ignored when there's no
existing archive or when at least one archive member must be updated
or deleted.
I am a bit new to maven, but I have some experiences with ant and the build process. I would like to do one thing that is kind of driving me nuts:
Given:
A remote repository (git, svn, hg,…) that holds static content (like images),
one maven project that uses/manages the mentioned repository in the same way as it does with all other dependencies (checkout on install, update whenever updates occur), in other words: the maven project depends on that repository
I finally want to be able to access the content (no *.svn or *.git) and copy it into my build, on build time*.
I want maven to store a local copy of that repository in maven`s local repository (~/.m2/repository) only once on each machine and manage it like all other dependencies.
*I am not trying to build a Java project
Thanks for help!
From what I've seen, Maven projects don't use version control repositories as external artifacts. That's a little too fine-grained for what you want, I think.
I've done something similar, when Project A wanted to use resources from Project B.
Project B, as part of its build procedure, collected it's resources into a ZIP file and deployed the ZIP file into a maven repository.
Project A then references the ZIP file artifact, unpacking it when building to where it needs it.
Look into the dependency plugin for maven, especially the dependency:unpack and dependency:unpack-dependencies goal.
Have fun
I have a Maven 2 multi-module project and want to be sure everything is taken from my local checked-out source.
Is it possible to tell Maven to never download anything for the modules it has the source of? Do I have to disable the remote repositories?
Does Maven always have to go the expensive way of installing a module into the local repository, and then extracting it again for each of its dependents?
Does Maven automatically first recompile dependencies for a module if their local source changed, and then compile the dependent?
Is it possible to tell Maven to never download anything for the modules it has the source of?
No. Maven 2 only "sees" the current module while it builds. On the plus side, you can build part of the tree by running Maven in a module.
Do I have to disable the remote repositories?
Yes, use the "offline" option -o or -offline. Or use settings.xml with a proxy that doesn't have any files. This isn't what you want, though.
Does Maven always have to go the expensive way of installing a module into the local repository, and then extracting it again for each of its dependents?
Yes but it's not expensive. During the build, the file is copied (that was expensive ten years ago). When a dependency is used, Maven just adds the path to the file to the Java process. So the file isn't copied or modified again. Maven assumes that files in the local repository don't change (or only change once when a download/install happens).
Does Maven automatically first recompile dependencies for a module if their local source changed?
No. There were plans for Maven 3 but I can't find an option to enable something like that.
To solve your issues, you should install a local proxy (like Nexus).
Maven download stuffs (dependencies) only if it's not available in your local reposiotory ($USER_HOME/.m2/repository). If you do not want anything to be downloaded use offline mode. This can be done by using -o switch. E.g.
mvn -o clean install
There is nothing expensive in it. If you are building the complete parent project, it will build all the modules and then copy the artifacts to your local repository. Then, when you build a project that has dependencies on those project, Maven will just copy them from local repository on your hard disk to the package that is going to be created for current project.
No. I have been burnt. Maven does not compile dependencies automatically. There is a plugin called Maven Reactor Plug-in. This plugin enables you to build a project's dependencies before the project is built.