org.nuiton.io.FileUpdaterHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of helper-maven-plugin-api Show documentation
Show all versions of helper-maven-plugin-api Show documentation
Simple maven mojo api for our projects
package org.nuiton.io;
/*
* #%L
* Helper Maven Plugin :: API
* $Id: FileUpdaterHelper.java 876 2012-11-11 08:14:19Z tchemit $
* $HeadURL: http://svn.nuiton.org/svn/maven-helper-plugin/tags/maven-helper-plugin-2.1/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdaterHelper.java $
* %%
* Copyright (C) 2009 - 2012 Codelutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.io.File;
/** @author tchemit */
public class FileUpdaterHelper {
static public MirroredFileUpdater newJavaFileUpdater() {
return newJavaFileUpdater(null, null);
}
static public MirroredFileUpdater newJaxxFileUpdater() {
return newJaxxFileUpdater(null, null);
}
static public MirroredFileUpdater newJavaFileUpdater(File src, File dst) {
return new JavaFileUpdater(src, dst);
}
static public MirroredFileUpdater newJaxxFileUpdater(File src, File dst) {
return new JaxxFileUpdater(src, dst);
}
/**
* To test if a java source file is newser than his compiled class
*
* @author tchemit
*/
public static class JavaFileUpdater extends MirroredFileUpdater {
protected JavaFileUpdater(File sourceDirectory,
File destinationDirectory) {
super(".java", ".class", sourceDirectory, destinationDirectory);
}
@Override
public File getMirrorFile(File f) {
String file =
f.getAbsolutePath().substring(prefixSourceDirecotory);
String mirrorRelativePath =
file.substring(0, file.length() - 4) + "class";
return new File(destinationDirectory + File.separator +
mirrorRelativePath);
}
}
/**
* To test if a jaxx source file is newser than his generated java
* source file.
*
* @author tchemit
*/
public static class JaxxFileUpdater extends MirroredFileUpdater {
protected JaxxFileUpdater(File sourceDirectory,
File destinationDirectory) {
super(".jaxx", ".java", sourceDirectory, destinationDirectory);
}
@Override
public File getMirrorFile(File f) {
String file =
f.getAbsolutePath().substring(prefixSourceDirecotory);
String mirrorRelativePath =
file.substring(0, file.length() - 4) + "java";
return new File(destinationDirectory + File.separator +
mirrorRelativePath);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy