Skip to content

Commit 7fc223c

Browse files
committed
## [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
1 parent b3f0534 commit 7fc223c

File tree

6 files changed

+48
-24
lines changed

6 files changed

+48
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ plugin-omt-package.iws
2828
.idea/misc.xml
2929
.idea/uiDesigner.xml
3030
.idea/vcs.xml
31+
register_omt.reg

CHANGELOG.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# Change Log
2-
All notable changes to this project will be documented in this file.
32

4-
## [Unreleased]
5-
6-
### Add
7-
- foo
8-
- boo
3+
## [v1.0.1]
94

105
### Changed
116

7+
- Title of the Export OMT dialog
8+
- Empty directories have ".empty" files instead of ".ignore" files
9+
- If there are projects folder inside the project to package, they are skipped.
10+
11+
- the Gradle task to install the plugin is `installPlugin`, but it requires you to change the `gradle.properties` file
12+
and modify the `omegatPluginDir`.
13+
14+
### Add
15+
- More logging when zipping the package.
16+
1217
### Fixed
18+
- Bug when zipping empty subdirectories, they would show up at the root of the package
19+
20+
## [v1.0.0]
1321

14-
[Unreleased]: https://github.com/miurahr/omegat-plugin-skelton/compare/v0.1...HEAD

build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
id 'distribution'
66
id 'maven'
77
id 'idea'
8+
id 'eclipse'
89
}
910

1011
repositories {
@@ -102,12 +103,10 @@ distributions {
102103
}
103104
}
104105

105-
task deployOmegaT(type: Copy) {
106-
106+
task installPlugin(type: Copy) {
107107
from 'build/install/plugin-omt-package/plugin'
108-
into omegatDir
108+
into omegatPluginDir
109109
include('*.jar')
110-
111110
}
112111

113-
installDist.dependsOn deployOmegaT
112+
installPlugin.dependsOn installDist

gradle.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pluginMainClass=net.briac.omegat.plugin.omt.ManageOMTPackage
22
pluginName=OMT Package Plugin
3-
version=1.0.0
4-
5-
omegatDir=C:/Users/briac/AppData/Roaming/OmegaT/plugins/
3+
version=1.0.1
4+
omegatPluginDir=C:/Users/briac/AppData/Roaming/OmegaT/plugins/

src/main/java/net/briac/omegat/plugin/omt/ManageOMTPackage.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
public class ManageOMTPackage {
5454

5555
public static final String OMT_EXTENSION = ".omt";
56-
public static final String IGNORE_FILE = ".ignore";
56+
public static final String IGNORE_FILE = ".empty";
5757
static final ResourceBundle res = ResourceBundle.getBundle("omt-package", Locale.getDefault());
5858
private static JMenuItem importOMT;
5959
private static JMenuItem exportOMT;
@@ -172,7 +172,7 @@ public static void projectExportOMT() {
172172
.endsWith(OMT_EXTENSION) ? ndm.getSelectedFile()
173173
: new File(ndm.getSelectedFile().getAbsolutePath() + OMT_EXTENSION);
174174

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

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

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

336336
final String name = childPath.toFile().getName();
337-
if (name.endsWith(OConsts.BACKUP_EXTENSION) || name.endsWith(OMT_EXTENSION)
337+
338+
// TODO - The list of excluded/included files should be read from a
339+
// properties file in OmT config folder.
340+
if (name.endsWith(".zip") || name.endsWith(OConsts.BACKUP_EXTENSION) || name.endsWith(OMT_EXTENSION)
338341
) {
339342
// Skip .bak and .omt files
340343
continue;
341344
}
342-
if (childPath.endsWith(OConsts.FILE_PROJECT)) {
345+
346+
// Skip projects inside projects
347+
if (Files.isDirectory(child) && new File(child.toFile(), OConsts.FILE_PROJECT).exists()) {
348+
Log.log(String.format("The directory \"%s\" appears to be an OmegaT project, we'll skip it.", child.toFile().getAbsolutePath()));
349+
continue;
350+
}
351+
352+
if (root == null && childPath.endsWith(OConsts.FILE_PROJECT)) {
343353
// Special case - when a project is opened, the project file is locked and
344354
// can't be copied directly. To avoid this, we make a temp copy.
345-
File tmpProjectFile = File.createTempFile("omt", null, props.getProjectRootDir());
355+
// We name it with a .bak extension to make sure it's not included in the package.
356+
File tmpProjectFile = File.createTempFile("omt", OConsts.BACKUP_EXTENSION, props.getProjectRootDir());
346357
try {
347358
ProjectFileStorage.writeProjectFile(props, tmpProjectFile);
348359
} catch (Exception e) {
349360
throw new IOException(e);
350361
}
362+
Log.log(String.format("addZipDir\tproject\t[%s]", OConsts.FILE_PROJECT));
351363
out.putNextEntry(new ZipEntry(OConsts.FILE_PROJECT));
352364
Files.copy(Paths.get(tmpProjectFile.getAbsolutePath()), out);
353365
out.closeEntry();
354-
tmpProjectFile.delete();
366+
boolean isTmpDeleted = tmpProjectFile.delete();
367+
if (!isTmpDeleted) {
368+
Log.log(String.format("Could not delete temporary file \"%s\". You can safely delete it.", tmpProjectFile.getAbsolutePath()));
369+
}
355370
continue;
356371
}
357372

@@ -360,11 +375,14 @@ private static final void addZipDir(final ZipOutputStream out, final Path root,
360375
// Before recursing, we add a ZipEntry for the directory to allow
361376
// empty dirs.
362377
if (child.toFile().listFiles().length == 0) {
363-
out.putNextEntry(new ZipEntry(name + File.separatorChar + IGNORE_FILE));
378+
String emptyDirFile = entry.toString() + File.separatorChar + IGNORE_FILE;
379+
Log.log(String.format("addZipDir\tempty\t[%s]", emptyDirFile));
380+
out.putNextEntry(new ZipEntry(emptyDirFile));
364381
out.closeEntry();
365382
}
366383
addZipDir(out, entry, child, props);
367384
} else {
385+
Log.log(String.format("addZipDir\tfile\t[%s]", entry));
368386
out.putNextEntry(new ZipEntry(entry.toString()));
369387
Files.copy(child, out);
370388
out.closeEntry();

src/main/resources/omt-package.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
omt.menu.import=Import OMT package...
2323
omt.menu.export=Export OMT package...
2424
omt.chooser.import=Select the OMT package to import
25-
omt.chooser.export=Select the OMT package to export
25+
omt.chooser.export=Select location and name of the OMT export
2626
omt.chooser.filter=OMT Package file
2727
omt.invalid.package=Invalid OMT package, file "omegat.project" is missing.
2828
omt.update.package=Updating current project with OMT package content

0 commit comments

Comments
 (0)