Skip to content

Commit

Permalink
## [v1.0.1]
Browse files Browse the repository at this point in the history
### Changed

- Title of the Export OMT dialog
- Empty directories have ".empty" files instead of ".ignore" files
- If there are projects folder inside the project to package, they are skipped.

- the Gradle task to install the plugin is `installPlugin`, but it requires you to change the `gradle.properties` file
and modify the `omegatPluginDir`.

### Add
- More logging when zipping the package.

### Fixed
- Bug when zipping empty subdirectories, they would show up at the root of the package
  • Loading branch information
briacp committed Mar 11, 2019
1 parent b3f0534 commit 7fc223c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ plugin-omt-package.iws
.idea/misc.xml
.idea/uiDesigner.xml
.idea/vcs.xml
register_omt.reg
21 changes: 14 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Change Log
All notable changes to this project will be documented in this file.

## [Unreleased]

### Add
- foo
- boo
## [v1.0.1]

### Changed

- Title of the Export OMT dialog
- Empty directories have ".empty" files instead of ".ignore" files
- If there are projects folder inside the project to package, they are skipped.

- the Gradle task to install the plugin is `installPlugin`, but it requires you to change the `gradle.properties` file
and modify the `omegatPluginDir`.

### Add
- More logging when zipping the package.

### Fixed
- Bug when zipping empty subdirectories, they would show up at the root of the package

## [v1.0.0]

[Unreleased]: https://github.com/miurahr/omegat-plugin-skelton/compare/v0.1...HEAD
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'distribution'
id 'maven'
id 'idea'
id 'eclipse'
}

repositories {
Expand Down Expand Up @@ -102,12 +103,10 @@ distributions {
}
}

task deployOmegaT(type: Copy) {

task installPlugin(type: Copy) {
from 'build/install/plugin-omt-package/plugin'
into omegatDir
into omegatPluginDir
include('*.jar')

}

installDist.dependsOn deployOmegaT
installPlugin.dependsOn installDist
5 changes: 2 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pluginMainClass=net.briac.omegat.plugin.omt.ManageOMTPackage
pluginName=OMT Package Plugin
version=1.0.0

omegatDir=C:/Users/briac/AppData/Roaming/OmegaT/plugins/
version=1.0.1
omegatPluginDir=C:/Users/briac/AppData/Roaming/OmegaT/plugins/
34 changes: 26 additions & 8 deletions src/main/java/net/briac/omegat/plugin/omt/ManageOMTPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
public class ManageOMTPackage {

public static final String OMT_EXTENSION = ".omt";
public static final String IGNORE_FILE = ".ignore";
public static final String IGNORE_FILE = ".empty";
static final ResourceBundle res = ResourceBundle.getBundle("omt-package", Locale.getDefault());
private static JMenuItem importOMT;
private static JMenuItem exportOMT;
Expand Down Expand Up @@ -172,7 +172,7 @@ public static void projectExportOMT() {
.endsWith(OMT_EXTENSION) ? ndm.getSelectedFile()
: new File(ndm.getSelectedFile().getAbsolutePath() + OMT_EXTENSION);

Log.log("\n\n*******\n********\n");
Log.log(String.format("Exporting OMT \"%s\"", omtFile.getAbsolutePath()));

// Check and ask if the user wants to overwrite an existing package
if (omtFile.exists()) {
Expand Down Expand Up @@ -314,7 +314,7 @@ public static void createOmt(final File omtZip, final ProjectProperties props) t
}

BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(omtZip));

Log.log(String.format("Zipping to file [%s]", omtZip.getAbsolutePath()));
try (ZipOutputStream out = new ZipOutputStream(bos)) {
addZipDir(out, null, path, props);
}
Expand All @@ -334,24 +334,39 @@ private static final void addZipDir(final ZipOutputStream out, final Path root,
final Path childPath = child.getFileName();

final String name = childPath.toFile().getName();
if (name.endsWith(OConsts.BACKUP_EXTENSION) || name.endsWith(OMT_EXTENSION)

// TODO - The list of excluded/included files should be read from a
// properties file in OmT config folder.
if (name.endsWith(".zip") || name.endsWith(OConsts.BACKUP_EXTENSION) || name.endsWith(OMT_EXTENSION)
) {
// Skip .bak and .omt files
continue;
}
if (childPath.endsWith(OConsts.FILE_PROJECT)) {

// Skip projects inside projects
if (Files.isDirectory(child) && new File(child.toFile(), OConsts.FILE_PROJECT).exists()) {
Log.log(String.format("The directory \"%s\" appears to be an OmegaT project, we'll skip it.", child.toFile().getAbsolutePath()));
continue;
}

if (root == null && childPath.endsWith(OConsts.FILE_PROJECT)) {
// Special case - when a project is opened, the project file is locked and
// can't be copied directly. To avoid this, we make a temp copy.
File tmpProjectFile = File.createTempFile("omt", null, props.getProjectRootDir());
// We name it with a .bak extension to make sure it's not included in the package.
File tmpProjectFile = File.createTempFile("omt", OConsts.BACKUP_EXTENSION, props.getProjectRootDir());
try {
ProjectFileStorage.writeProjectFile(props, tmpProjectFile);
} catch (Exception e) {
throw new IOException(e);
}
Log.log(String.format("addZipDir\tproject\t[%s]", OConsts.FILE_PROJECT));
out.putNextEntry(new ZipEntry(OConsts.FILE_PROJECT));
Files.copy(Paths.get(tmpProjectFile.getAbsolutePath()), out);
out.closeEntry();
tmpProjectFile.delete();
boolean isTmpDeleted = tmpProjectFile.delete();
if (!isTmpDeleted) {
Log.log(String.format("Could not delete temporary file \"%s\". You can safely delete it.", tmpProjectFile.getAbsolutePath()));
}
continue;
}

Expand All @@ -360,11 +375,14 @@ private static final void addZipDir(final ZipOutputStream out, final Path root,
// Before recursing, we add a ZipEntry for the directory to allow
// empty dirs.
if (child.toFile().listFiles().length == 0) {
out.putNextEntry(new ZipEntry(name + File.separatorChar + IGNORE_FILE));
String emptyDirFile = entry.toString() + File.separatorChar + IGNORE_FILE;
Log.log(String.format("addZipDir\tempty\t[%s]", emptyDirFile));
out.putNextEntry(new ZipEntry(emptyDirFile));
out.closeEntry();
}
addZipDir(out, entry, child, props);
} else {
Log.log(String.format("addZipDir\tfile\t[%s]", entry));
out.putNextEntry(new ZipEntry(entry.toString()));
Files.copy(child, out);
out.closeEntry();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/omt-package.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
omt.menu.import=Import OMT package...
omt.menu.export=Export OMT package...
omt.chooser.import=Select the OMT package to import
omt.chooser.export=Select the OMT package to export
omt.chooser.export=Select location and name of the OMT export
omt.chooser.filter=OMT Package file
omt.invalid.package=Invalid OMT package, file "omegat.project" is missing.
omt.update.package=Updating current project with OMT package content
Expand Down

0 comments on commit 7fc223c

Please sign in to comment.