Latest stable revision with ivy excluding alpha & beta releases - ivy

For our project we like to have most dependecies automaticaly up to date so we want to use the lastest strategies in IVY. However we dont want to run the bleeding edge of the dependencies ie. alpha and beta versions.
When using:
<dependency org="org.apache.httpcomponents" name="httpclient" rev="latest.revision" />
or
<dependency org="org.apache.httpcomponents" name="httpclient" rev="latest.release" />
We get revision 4.4-alpha1
This is understandable as we use the ibiblio resolver which contains the following xml in maven-metadata.xml
<metadata>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<versioning>
<latest>4.4-alpha1</latest>
<release>4.4-alpha1</release>
<versions>
<version>4.0-alpha1</version>
<!-- snip --->
<version>4.3-alpha1</version>
<version>4.3-beta1</version>
<version>4.3-beta2</version>
<version>4.3</version>
<version>4.3.1</version>
<version>4.3.2</version>
<version>4.3.3</version>
<version>4.3.4</version>
<version>4.3.5</version>
<version>4.4-alpha1</version>
</versions>
<lastUpdated>20140801101402</lastUpdated>
</versioning>
</metadata>
The meta data indicates the alpha version as both release and latest. (not sure if this is related actualy)
In this case we there is a version we would like to get in the metadata list being 4.3.5
Now ivy has a construct with and but the documentation is quite sparse, and i cant figure out how to make this strategy 'ignore' the alpha release.
I tried variation of the following to no avail (using rev="latest.test") :
`
Edit:
From the source code of org.apache.ivy.plugins.latest.LatestRevisionStrategy it appears specialmeanings wont be able to solve this since the version is first split in parts and then compared on a part by part basis.
If there is a way to forbid revisions that contain a specific string my problem would also be solved.
`

The source code of org.apache.ivy.plugins.latest.LatestRevisionStrategy indicated it's impossible to fix this with special-meaning strings in a latestStrategy element. (thanks to: this post)
we ended up using a version matcher to enforse ivy to not use -beta- or -alpha releases.
Its not an optimal solution and the regexp probably needs to be updated a few times still.
in ivysettings.xml:
<version-matchers usedefaults="true">
<pattern-vm name="lastest.nobeta">
<match revision="latest.nobeta" pattern="\.*\d+\.\d+\.?\d*(FINAL|RELEASE|STABLE)?" matcher="regexp" />
</pattern-vm>
</version-matchers>
and in ivy.xml:
<dependency org="org.apache.poi" name="poi" rev="latest.nobeta"/>
Not entirely sure if this takes the lastest version but so far that seems to be the case.

Related

How to get Directory name in msbuild configuration file?

Here is the simple code which I am using. Which gets all the folders in the directory and then give me the Folder name.
<TestProjectFolderPath Include="$([System.IO.Directory]::GetDirectories(`$(SolutionDir)`,`*.Tests`))" />
<TestProjectFolderNames Include="#(TestProjectFolderPath->'$([System.IO.Path]::GetDirectoryName(`$([System.IO.Path]::GetFileName(`%(Identity)`))`)',' ')" />
But in TestProjectFolderNames [System.IO.Path] functions are not getting evaluated and returned as just string eg:
$([System.IO.Path]::GetDirectoryName($([System.IO.Path]::GetFileName(C:\Some.Unit.Tests)))
I need help to understand the correct syntax to get this working.
Using property functions on Item Metadata while transforming an Item is not supported I think (maybe it is in the latest MSBuild version but I cannot test that right now). As a workaround add new Metadata yourself and because it acts like a Property things work out ok for recent MSBuild versions:
<ItemGroup>
<TestProjectFolderPath Include="$([System.IO.Directory]::GetDirectories(`$(SolutionDir)`,`*.Tests`))" />
<TestProjectFolderPath>
<FolderName>$([System.IO.Path]::GetFileName(`%(Identity)`))</FolderName>
</TestProjectFolderPath>
</ItemGroup>
<Message Text="#(TestProjectFolderPath->'%(FolderName)', ' ')" />
edit see comments, according to Sherry for older MSBuild versions the equivalent Item code is:
<TestProjectFolderPath Include="$([System.IO.Directory]::GetDirectories($(SolutionDir),*.Tests))">
<FolderName>$([System.IO.Path]::GetFileName(%(Identity)))</FolderName>
</TestProjectFolderPath>
I left out GetDirectoryName because it makes little sense calling that on the result of GetFileName.

Referencing a sibling changeset in a rollback section

I'm having an issue trying to rollback a changeSet by referring sibling-changeset.
master-changelog.xml
includes v.1.changes.xml (here is the table created)
includes v.2.changes xml (here the table dropped and I would like to refer a changeset from v.1.changes.xml as a rollback)
However no matter how do I reference the changeset in v.1.changes.xml it's not visible to v.2.changes.xml and I'm getting liquibase.exception.SetupException: liquibase.parser.core.ParsedNodeException: Change set not found.
master-changelog.xml
<include file="v1/v1.changes.xml" relativeToChangelogFile="true"/>
<include file="v2/v2.changes.xml" relativeToChangelogFile="true"/>
v1.changes.xml
<changeSet id="1" author="dima">
<createTable tableName="test-table">
<column name="test" type="number"></column>
</createTable>
</changeSet>
v2.changes.xml
<changeSet id="1" author="dima">
<dropTable tableName="test"/>
<rollback changeSetAuthor="dima" changeSetId="1" changeSetPath="src/main/resources/std/v1/v1.changes.xml"/>
</changeSet>
It appears that you're using Maven, so this answer will be Maven specific, as I have not been able to reproduce the solution on the command line.
First of all, it's possible that Liquibase is confused because you're using the same changeSet id in both files, and I'm not sure if it correctly scopes those ids to the changeSet file, or if the ids need to be global. You might first try changing the id on the second changeSet and see if it clears it up for you.
If that's not the issue, then the trick to getting this to work is to make sure your relative references are all in the context of the Java classpath. As I interpret your example, the classpath resources of your files would be:
std/master-changelog.xml
std/v1/v1.changes.xml
std/v2/v2.changes.xml
When running your migration, your changeLogFile setting should reference the classpath resource, not the disk file; i.e. std/master-changelog.xml instead of src/main/resources/std/master-changelog.xml. This puts the origin changelog in a classpath context rather than a file context.
In your v2.changes.xml, you then refer to the first change using the classpath resource name: v1/v1.changes.xml. This should allow Liquibase to find it correctly.
If you have more than one level of changeLog file inclusion, you might be running into this issue which prevents Liquibase from finding sibling changeLogs below the first level of inclusion. Until the pull request is merged and released, you'll be limited to a single level of file inclusion.
This solution is assuming you're using the Maven plugin, liquibase will still find the changelog, since Maven puts your resource files on the classpath by default. I also attach the plugin to the process-resources step (or later) so that the source resources will be in the target/classes directory when the migration is run.

how to add working sets to eclipse common navigator?

I would love to add support for Working Sets for my Eclipse plugin that used the Common Navigator framework.
In Eclipse bugzilla there is mention that this is supported
None of the online manuals for the Common Navigator explain how to do it
I do not know where to start even since there is no extension point for it, and the Working Set implementation classes are all "internal". I have a very basic navigator setup showing default project resources and some additional IFileSystem stuff implementing ITreeContentProvider.
You can get the working set manager using:
IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
and from that get the visible working sets with:
IWorkingSet [] workingSets = manager.getWorkingSets();
the members of a working set can be accessed with:
IAdaptable [] elements = workingSet.getElements();
so you could use the working sets list as the input for the tree viewer and adjust your tree content provider to deal with this.
In retrospect the following is a better solution. Instead of implementing ITreeContentProvider and traversing the working sets ourselves, we can reuse existing standard providers for the same content, which might work better.
You can use them like so:
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerContentBinding
viewerId="rascal.navigator">
<includes>
<contentExtension pattern="org.eclipse.ui.navigator.resourceContent" />
<contentExtension pattern="org.eclipse.ui.navigator.resources.filters.*"/>
<contentExtension pattern="org.eclipse.ui.navigator.resources.linkHelper"/>
<contentExtension pattern="org.eclipse.ui.navigator.resources.workingSets"/>
</includes>
</viewerContentBinding>
In particular the org.eclipse.ui.navigator.resources.workingSets is what adds working sets capabilities to your navigator.
Adding your own content then becomes an issue of adding another content provider which ignores workingsets and projects and other kinds of resources which are already taken care of, e.g. like so:
<extension
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
activeByDefault="true"
contentProvider="org.rascalmpl.eclipse.navigator.NavigatorContentProvider"
id="org.rascalmpl.navigator.searchPathContent"
labelProvider="org.rascalmpl.eclipse.navigator.NavigatorContentLabelProvider"
name="Rascal search path"
priority="normal">
<triggerPoints>
<or>
<instanceof value="org.eclipse.core.resources.IResource"/>
</or>
</triggerPoints>
<possibleChildren>
<or>
<instanceof value="java.lang.Object"/>
</or>
</possibleChildren>
<actionProvider
class="org.rascalmpl.eclipse.navigator.NavigatorActionProvider"
id="org.rascalmpl.navigator.actions">
</actionProvider>
<commonSorter
class="org.rascalmpl.eclipse.navigator.Sorter">
</commonSorter>
</navigatorContent>
<commonWizard
type="new"
wizardId="rascal_eclipse.wizards.NewRascalFile">
<enablement></enablement>
</commonWizard>
<commonWizard
type="new"
wizardId="rascal_eclipse.projectwizard">
<enablement></enablement>
</commonWizard>
</extension>
and in the NavigatorContentProvider class we implement getElements and getChildren but only for our own additional content.

CA1703 CodeAnalysis Error and CasingExceptions

I have a text resource "{0} by Test GmbH" which is correctly spelled because GmbH is the official Abbreviation for "Gesellschaft mit beschränkter Haftung". I understand that Microsoft CodeAnalysing tries to tokenize it into "Gmb" and "H" however I think it should be possible to introduce this term as known with that specific spelling and casing with this CodeAnalysingDictionary:
<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
<Words>
<Unrecognized>
</Unrecognized>
<Recognized>
<Word>Gmbh</Word>
</Recognized>
<Deprecated>
</Deprecated>
<DiscreteExceptions>
<Term>GmbH</Term>
</DiscreteExceptions>
</Words>
<Acronyms>
<CasingExceptions>
<Acronym>GmbH</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>
However it does not work out:
CA1703 Resource strings should be spelled correctly
In resource 'MyCode.Properties.Resources.resx',
referenced by name 'CopyrightWithCompanyName',
correct the spelling of 'Gmb' in string value '{0} by Test GmbH'.
How can I adjust the dictionary correctly?
Actually, provided that GmbH should be interpreted as a compound word that consists of the words Gmb and H, the casing of GmbH is correct.
So, in order for GmbH to be seen as valid by Code Analysis and thereby eliminate CA1703, simply add gmb as a recognized word to your custom dictionary file:
<Dictionary>
<Words>
<Recognized>
<Word>gmb</Word>
<!-- ... -->
</Recognized>
<!-- ... -->
</Words>
<!-- ... -->
</Dictionary>
I confirmed that this works in Visual Studio 2013.
According to http://msdn.microsoft.com/en-us/library/bb514188.aspx#bkmk_dictionaryacronymscasingexceptionsacronym
entries in the CasingExceptions are only applied to CA1709: Identifiers should be cased correctly, not to resources.
I have the exact same problem but no solution other then suppress the warning

Performing Simple Calculations with Native Ant Tasks

Using only native ANT tasks, how can I create a custom ANT task to do the following:
Calculate the the number of days since January 1, 2000 local time and store it in a property.
Calculate the number of seconds since midnight local time, divided by 2 and store it in a property.
The above property values will then be appended to others and written to a file.
ANT is not a general purpose programming language, so you need to write a custom task or alternatively use something like the groovy plugin
The following example demonstrates how a groovy task using the Joda Time library can set the properties as you've specified.
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<groovy>
import org.joda.time.*
def now = new DateTime()
def midnight = new DateMidnight()
def year2000 = new DateTime(2000,1,1,0,0,0,0)
properties["year2000.days"] = Days.daysBetween(year2000, now).days
properties["midnight.seconds"] = Seconds.secondsBetween(midnight, now).seconds
properties["midnight.seconds.halved"] = Seconds.secondsBetween(midnight, now).dividedBy(2).seconds
</groovy>
I can't recommend Joda Time highly enough, standard Date and Time manipulation in Java just sucks!
Additional notes
The groovy task above will require the following jars on your classpath:
groovy-all-1.7.4.jar
joda-time-1.6.1.jar
I'd recommend using the ivy plugin to manage these by adding a "resolve" target that downloads the jars and sets the classpath automatically:
<target name="resolve">
<ivy:resolve/>
<ivy:cachepath pathid="build.path"/>
</target>
The following is the ivy.xml that lists the dependencies to be downloaded:
<ivy-module version="2.0">
<info organisation="org.myspotontheweb" module="demo"/>
<dependencies>
<dependency org="org.codehaus.groovy" name="groovy-all" rev="1.7.4" conf="default"/>
<dependency org="joda-time" name="joda-time" rev="1.6.1" conf="default"/>
</dependencies>
</ivy-module>