I'm trying to learn how to use ivy and would like to setup a local repository of the .jar files I've downloaded.
Where do you put the ivysettings.xml file? Does it go in the ant library directory?
If you'll allow me to clarify, the ivysettings.xml is the configuration of your development environment as a whole. It is not related to the repository items themselves. Generally speaking, ivysettings.xml should sit alongside your main build.xml, so that when you put
<ivy:settings file="ivysettings.xml"/>
in your build.xml, it just finds it in the current directory.
This file is completely distinct from the ivy.xml files that describe the various modules in your repository. These sit alongside the published artifacts in the repo.
You can place your ivysettings.xml file anywhere you want and you simply reference it in your Ant script with:
<ivy:settings file="ivysettings.xml"/>
If you are developing several projects, you will notice that you typically use the same ivysettings.xml file everywhere and there's no point in copy/pasting this file manually.
What I do is define one ivysettings.xml file that is checked out by all my other projects using svn:externals.
I have had the same fun with this toady, and have found you can put the ivysettings.xml file anywhere you like, but you simply reference this location on the commandline when you come to use it. e.g. You can call Ivy from NAnt something like this:
<exec program="java"
commandline=" ... ...
-jar [location of .jar file]
-settings [location of ivysettings.xml file]
... ..."
/>
(where ... means something uninteresting has been removed to save space)
Reference:
ivy settings doc
Related
I have a little sandbox that I use to publish not-invented-here artifacts to our artifact repository. It has a common build.xml file and a common ivysettings.xml.
I would like to be able to pass the name of the ivy.xml file so I can have exactly one, uniquely-named someartifact-ivy.xml file per artifact I intend to publish.
I tried the following:
#/bin/sh
ant publish -Divy.settings.file=ivy-external-ivysettings.xml -Divy.dep.file=someartifact-ivy.xml
Property -Divy.settings.file=ivy-external-ivysettings.xml succeeds in causing ivy to use my ivy-external-ivysettings.xml file.
However, ivy seems to ignore property -Divy.dep.file=someartifact-ivy.xml and goes looking for ivy.xml instead.
The docs suggest to me that my approach should work, as does an upvoted (currently x6) answer to a similar question.
I have a ASP.net project that i need to run SonarQube analysis on and i have configured it with Jenkins to run the analysis. The analysis is running fine but it is including the bower_components and node_modules i have in the project. The way the project is structured there are multiple node_modules and bower_component folders in the projects folder structure. So i need to exclude them all in a pattern. I have added a SonarQubeSetting section to the .csproj file and i have the current values for exclusion.
<Target Name="BeforeBuild">
<ItemGroup>
<SonarQubeSetting Include="sonar.exclusions">
<Value>**\main-built.js,**\template-build.js,**\kendo*.js,**\bower_components\*,**\node_modules\*</Value>
</SonarQubeSetting>
</ItemGroup>
</Target>
Using **\bower_components\* **\node_modules\* did not work and the libraries are still picked up and scanned. How can i exclude folder (in my case node_modules & bower_components) content regardless of its location in the directory structure in sonar?
The last time I setup Sonar, I am pretty sure the sonar.exclusion property worked as expected... Perhaps your naming pattern is a little off. For example, how about a ** at the end rather than *. See this answer for examples and answers when using naming patterns.
I'm still struggling with figuring out how to integrate Apache Ivy into my somewhat complex Ant build.
If it matters, I'm using ATG Dynamo, which contributes most of the mess I'm trying to deal with.
The result of a build of a module is a "build" directory, with several subdirectories. I need to publish the entire contents of the "build" directory, along with a properties file (env/default.properties) that is not produced by the build, but one property in that file is needed when later retrieving this artifact, as it indicates the absolute path (relative to another property setting) where the contents of the "build" directory need to be installed.
The entire build will have several similarly structured modules. I'm pretty sure the target that does the "ivy:publish" can be defined in a "base" build script that all the module build scripts import.
I imagine the "ivy.xml" for each module would have a "publications" element that specifies the two (?) pieces that are being published, being the "build" directory and the "env/default.properties" file. I've never seen an example that publishes a directory, is that possible? If not, then I would guess that I'd have to specify more processing and detail in the "ivy:publish" target, such that I would first zip up the "build" directory and the "env/default.properties" file both into a zip file and publish that as the single artifact. Is this more likely?
It is quite new in Ivy, and it is not released yet, but there is a concept of "packaging" which can handle directories.
See the official documentation: http://ant.apache.org/ivy/history/trunk/concept.html#packaging
With this feature, Ivy can handle by itself the unzipping of a folder. On the publish part, you are on your own, you'll have to make a zip yourself. On the retrieve part, Ivy will unzip the folder in the cache. So you will still have to do some process to copy it at the proper place.
It has not been tested, but probably you can go even further by implementing a custom unpacking algorithm, which will do the unpacking at the proper place. You'll have to implement a class which extends org.apache.ivy.core.pack.ArchivePacking, and declare it in your ivysettings.xml, like this:
<ivysetting>
<classpath file="${ivy.settings.dir}/custom-packing.jar"/>
<typedef name="customPacking" classname="com.acme.ivy.CustomPacking" />
<customPacking />
</ivysettings>
And then in your ivy.xml, declare your artifact as packaged by your custom packaging name:
<ivy-module version="1.0">
...
<publications>
<artifact name="mydistrib" type="distrib" ext=".zip" packaging="my-custom-packaging" />
</publications>
</ivy-module>
In project A's build file, there is a <path>;
In project B's build file, I want to execute a tool class in project A by <java> task.
The <java> task need to use that path in its "classpathref" property.
The <path> in project A's build file is quite complicated so that I don't want to copy it to project B's build file.
So is it possible to refer to a classpath defined in one build file from another build file?
Using the import or include ANT tasks is the way to do this.... however, these are both designed build multi-module builds. It's generally a really bad idea to couple two different projects in this manner....
I understand the motivation, classpath management is one of the most important and error-prone parts of a Java build. My recommendation is to adopt Apache ivy and let it manage your build's 3rd party dependencies.
Example:
The ivy cachepath task to create your ANT path, using dependency declarations.
<ivy:cachepath pathid="test.path">
<dependency org="org.slf4j" name="slf4j-simple" rev="1.6.4" conf="default"/>
<dependency org="junit" name="junit" rev="4.10" conf="default"/>
</ivy:cachepath>
The jars themselves can be locally stored or retrieved from the Maven Central repository
Ant allows to import a project file into another. You may check section 'Resolving files against the imported file' as this will be needed in most cases.
I have a log4j.properties that sit right under the src folder. When I building my war file using ANT tool, the particular properties file wasn't pack inside WEB-INF/classes folder, and it was right under the "root" directory of the war file (if you unwar it). I heard from my colleague mention that this is not correct. May I know is this true? If no, how should I correct it?
THanks #!
Yes, log4j.properties (or any other resource loaded from the classpath) should be at the root of your Java source folder (src/main/java, build/main, src, JavaSource, or however you have your project configured).
In the WAR, it should be under WEB-INF/classes, not at the root (as if you unzipped it).
If this is not the case, being able to see your ANT build file would be very helpful. You should have something like this line configured within your war task:
<classes dir="build/main"/>
As long as you have a build/main/log4j.properties in your Ant basedir, this should work as you're expecting.