Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* modify pom.xml to enable new m2e eclipse plugin
* JENKINS-11062: fix broken tests and adopt help text

git-svn-id: https://svn.jenkins-ci.org/trunk/hudson/plugins/thinBackup@40112 71c3de6d-444a-0410-be80-ed276b4c234a
  • Loading branch information
tofuatjava committed Nov 11, 2011
1 parent 65a80f7 commit 2eb9740
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 12 deletions.
106 changes: 103 additions & 3 deletions pom.xml
@@ -1,10 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.395</version><!-- which version of Hudson is this plugin built against? -->
<relativePath />
<version>1.396</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>thinBackup</artifactId>
Expand Down Expand Up @@ -94,4 +94,104 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<versionRange>[1.63,)</versionRange>
<goals>
<goal>resolve-test-dependencies</goal>
<goal>apt-compile</goal>
<goal>insert-test</goal>
<goal>test-hpl</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<versionRange>[0.9,)</versionRange>
<goals>
<goal>display-info</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<versionRange>[0.9,)</versionRange>
<goals>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jvnet.localizer</groupId>
<artifactId>maven-localizer-plugin</artifactId>
<versionRange>[1.8,)</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.kohsuke</groupId>
<artifactId>access-modifier-checker</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>enforce</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<versionRange>[2.10,)</versionRange>
<goals>
<goal>test</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Expand Up @@ -69,7 +69,6 @@ public void doBackupManual(final StaplerRequest res, final StaplerResponse rsp)
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);

final ThinBackupPeriodicWork manualBackupWorker = new ThinBackupPeriodicWork() {
@SuppressWarnings("unused")
@Override
protected void execute(final TaskListener arg0) throws IOException, InterruptedException {
backupNow(BackupType.FULL);
Expand Down
Expand Up @@ -56,7 +56,6 @@ public long getRecurrencePeriod() {
return MIN;
}

@SuppressWarnings("unused")
@Override
protected void execute(final TaskListener arg0) throws IOException, InterruptedException {
final long currentTime = System.currentTimeMillis();
Expand Down
Expand Up @@ -34,7 +34,6 @@ public void removeEmptyDirectories(final File rootDir) throws IOException {
walk(rootDir, null);
}

@SuppressWarnings("unused")
@Override
protected void handleDirectoryEnd(final File directory, final int depth,
@SuppressWarnings("rawtypes") final Collection results) throws IOException {
Expand Down
Expand Up @@ -134,16 +134,18 @@ private boolean restoreFromZipFile() throws IOException {

private void restore(final File toRestore) throws IOException {
IOFileFilter nextBuildNumberFileFilter = FileFilterUtils.nameFileFilter("nextBuildNumber");
IOFileFilter restoreNextBuildNumberFilter = FileFilterUtils.notFileFilter(nextBuildNumberFileFilter);
IOFileFilter restoreNextBuildNumberFilter;

if (restoreNextBuildNumber) {
restoreNextBuildNumberFilter = FileFilterUtils.trueFileFilter();

Collection<File> restore = FileUtils.listFiles(toRestore, nextBuildNumberFileFilter, TrueFileFilter.INSTANCE);
Map<String, Integer> nextBuildNumbers = new HashMap<String, Integer>();
for (File file : restore) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
nextBuildNumbers.put(file.getParent(), Integer.parseInt(reader.readLine()));
nextBuildNumbers.put(file.getParentFile().getName(), Integer.parseInt(reader.readLine()));
} finally {
if (reader != null)
reader.close();
Expand All @@ -156,14 +158,16 @@ private void restore(final File toRestore) throws IOException {
try {
reader = new BufferedReader(new FileReader(file));
int currentBuildNumber = Integer.parseInt(reader.readLine());
Integer toRestoreNextBuildNumber = nextBuildNumbers.get(file.getParent());
Integer toRestoreNextBuildNumber = nextBuildNumbers.get(file.getParentFile().getName());
if (currentBuildNumber < toRestoreNextBuildNumber)
restoreNextBuildNumber(file, toRestoreNextBuildNumber);
} finally {
if (reader != null)
reader.close();
}
}
} else {
restoreNextBuildNumberFilter = FileFilterUtils.notFileFilter(nextBuildNumberFileFilter);
}

FileUtils.copyDirectory(toRestore, this.hudsonHome, restoreNextBuildNumberFilter, true);
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/help/help-backupNextBuildNumber.html
Expand Up @@ -27,6 +27,7 @@
If this option is enabled, the file <i>nextBuildNumber</i> will also be backed up.
</p>
<p>
<b>NOTE:</b><br/>Take special care when restoring a backup that contains a <i>nextBuildNumber</i> file, as this may potentially cause a lot of problems.
<b>NOTE:</b><br/>
In the case that the existing build number is greater than the build number that should be restored the build number will not be restored. This should prevent from situations where the build number is not unique anymore.
</p>
</div>
Expand Up @@ -23,7 +23,6 @@ public List<String> getFilesAsString(final File rootDir) throws IOException {
return result;
}

@SuppressWarnings("unused")
@Override
protected void handleFile(final File file, final int depth, @SuppressWarnings("rawtypes") final Collection results)
throws IOException {
Expand Down
Expand Up @@ -147,7 +147,7 @@ public void testRestoreFromDirectoryWithNextBuildNumber() throws Exception {
final FileCollector fc = new FileCollector();
final List<String> restoredFiles = fc.getFilesAsString(root);
final int nrRestored = restoredFiles.size();
Assert.assertEquals(originalFiles.size(), nrRestored + 2); // + 2 because original has more files that were not
Assert.assertEquals(originalFiles.size(), nrRestored + 1); // + 2 because original has more files that were not
// backed up on purpose (next build number, secret.key)
Assert.assertTrue(containsStringEndingWith(restoredFiles, HudsonBackup.NEXT_BUILD_NUMBER_FILE_NAME));
Assert.assertFalse(containsStringEndingWith(restoredFiles, "secret.key"));
Expand Down

0 comments on commit 2eb9740

Please sign in to comment.