How to remove SVN history from java files? - regex

I have various projects that had files with SVN history in them. I recently moved those projects to a Mercurial repository so now that history within the file is useless. Is there a way to remove those which is not by hand?
Here's an example:
/*
* $Rev:x$
* $LastChangedDate:x$
* $LastChangedBy:x$
*/
Where x is a value in the files. I assume some sort of regex would help. Any idea?
Edit:
This is the working answer:
<target name="remove-svn-history">
<replaceregexp byline="false" match="\A/\*.*?\*/" replace="">
<fileset dir="src" includes="**/*.java"/>
</replaceregexp>
</target>

Assuming that's at the beginning of the file, you could match it with the following regex:
\A/\*.*?\*/

Related

Ant replace task using replacefilterfile only on certain lines

I need to process and replace values on my files based on match/replace lines defined into a property file.
<replace dir="${build.dir}" replacefilterfile="replmap.properties">
<include name="**/*.js"/>
<include name="**/*.html"/>
</replace>
The problem is that I want to limit these replaces to be applied only to lines that don't contain certain string value (before or after the match).
I read documentation about replaceregexp searching an alternative solution, but I can't see a way to take de matches/replaces from a properties file.

Crashplan and regex - excluding files based on filename

Crashplan allows for excluding files from a backup set by using regex for the exclusion criteria (there is no inclusion criteria functionality). For my particular use case I have a folder that contains these files:
C_VOL-b001.spf
C_VOL-b001-i001.md5
C_VOL-b001-i001.spi
E_VOL-b001.spf
E_VOL-b001-i001.md5
E_VOL-b001-i001.spi
F_VOL-b001.spf
F_VOL-b001-i001.md5
F_VOL-b001-i001.spi
G_VOL-b001.spf
G_VOL-b001-i001.md5
G_VOL-b001-i001.spi
and I want to exclude any file that doesn't begin with the C_VOL filename. These are backup files from another backup software, Shadowprotect, but I only want to include the C volume files and exclude the others. The incremental files will continue to be added to each of the volume sets using the naming schema of -i001, -i002, etc.
So far I've tried the following:
^E_VOL
^E_VOL.*
and a few other variations, with no success. I'm not sure if Crashplan only allows for selecting based on the filetype extension (their regex examples are here http://goo.gl/qDAEcR ). They do mention that "Note that CrashPlan treats all file separators as forward slashes (/)."
I'm not sure if Crashplan recognizes all regex expressions. If it helps, back in 2008 I emailed their tech support with a regex question and one of the founders of Crashplan, Matt Dornquast, helped me with a the following regex:
I am trying to exclude any file that either:
1. have an extension of .spf, or
2. has a file name of the type, XXXXXX-cd.spi
3. But also allow for backup of files with the name type of, xxxxx.spi
And his regex worked perfectly:
(?i).+(?:\-cd\.spi|\.spf)$
I've contacted their tech support again but they said they will no longer help with regex questions.
It seems that you could use the following regex:
.*/C_VOL.*
I created this based on this example (link) they featured on the website you linked in your question. Please let us know if it's working :)

Camel-case column-names: Howto generate a sql column with underscore in EclipseLink like Hibernates ImprovedNamingStrategy does

I'm moving from Hibernate to EclipseLink.
What I realized is, that Hibernates ddl-generation creates underscore-separated sql-columns for camel-case columns with
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy" />
in my persistence.xml. I like that a lot.
My question is: How can I get EclipseLink to do that?
Jonny
I found a solution. You have to use the EclipseLink Session-Customizer class.
Explained here (with an example if you scroll down that page): http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg00094.html
Jonny
Fork this https://gist.github.com/iromu/6864061 . Numbers are not recognized as chars to be surrounded with underscores, you can override the mapping with #Column(name="")

HOW: Apache Camel, Regex match files

im experimenting in getting camel to do some file operations and pass them through the activeMQ broker, ive taken this project over from a guy who recently quit.
what ive got so far:
<route id="SVLFTPCOPY">
<from uri="sftp://*****:*******#********/srv/test/?fileName=*2280.xls&noop=true&idempotent=false"/>
<to uri="file:/srv/data/test/destination/"/>
<to uri="activemq:queue:svl.ftp.copy"/>
</route>
it works to the point where it runs the route without throwing any errors, but still doesnt copy the file to the local file.
Any ideas?
.
Yeah you need to use the include/exclude/filter option if you want to filter out files based on patterns. The fileName option is for a single file.
So in your case, remove fileName option and replace it with include=.*2280.xsl. Mind that the include is based on Java regular expressions, so we use dot star to indicate wildcard. More details here: https://camel.apache.org/components/latest/file-component.html. The ftp component inherits 99% of the options of the file component, so that is why I refer to the file wiki page.
Use the include option that uses Java regular expression:
include=.*2280\\.xsl
Please, mind the \\ before the dot .
Alternatively, use antInclude:
antInclude=*2280.xsl
For that kind of filtering I recommend to use the GenericFileFilter
In the implementation of name matching, the following code is used:
if (ObjectHelper.isNotEmpty(endpoint.getInclude())) {
if (!name.matches(endpoint.getInclude())) {
return false;
}
}
So you can test which regular expression you should use. In you case, I think .*2280\\.xsl is what you should use.

using MSBuild.ExtensionPack.FileSystem.File Replace on vdproj

Im trying to replace the ProductName held inside a Visual Studio setup project by performing a regex on the file in my msbuild script. To do the regEx replacement Im trying to use msbuild extension pack and in particular its File task. The target inside my msbuild script looks like this:
<Target Name="CustomiseMsi">
<PropertyGroup>
<RegExPattern>
<![CDATA[(?:\""ProductName\"" = \""8:.*)]]>
</RegExPattern>
<RegExReplacement>
<![CDATA["\"ProductName\" = \"8:MyApp v1.0\""]]>
</RegExReplacement>
<RegExOutput></RegExOutput>
</PropertyGroup>
<MSBuild.ExtensionPack.FileSystem.File
TaskAction="Replace"
RegexPattern="$(RegExPattern)"
Replacement="$(RegExReplacement)"
Files="#(AbsolutePathToVdProjToParse)">
</MSBuild.ExtensionPack.FileSystem.File></Target>
When this target runs I get the following output, but the file remains unchanged.
CustomiseMsi:
Processing File Collection
Processing File: C:\pathHere\mySetup.vdproj
Am I going about this right way? Has anyone done regex updated on a vdproj (or anything else) in this manner?
I had this same issue and after trying a few things, I got this to work...
<MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace"
TextEncoding="ASCII" RegexPattern='"ProductVersion" = "8:.*"'
Replacement='"ProductVersion" = "8:$(Version)"'
Files="%(Solution.DeploymentProject)"/>
This will simply replace the ProductVersion string with the version that I have in my Solution.DeploymentProject variable.
I dont believe you need to mess with CDATA at all.