diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d6261b4..2e3870b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,6 +21,9 @@ jobs: with: java-version: '11' distribution: 'adopt' + - name: Install required tools + run: | + sudo bash required.sh - name: maven-settings uses: s4u/maven-settings-action@v2 with: @@ -32,5 +35,5 @@ jobs: - name: Upload Maven build artifact uses: actions/upload-artifact@v2 with: - name: lilypond-converter-0.1.jar - path: /home/runner/work/lilypond-converter/lilypond-converter/target/lilypond-converter-0.1.jar + name: artifact + path: /home/runner/work/lilypond-converter/lilypond-converter/target/lilypond-converter-*.jar diff --git a/.gitignore b/.gitignore index b9daa88..6f1f632 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ !*.ent !*.xsd !*.yml +!test-input.*.zip +!required.sh diff --git a/pom.xml b/pom.xml index f6d0b10..034e16d 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,13 @@ + + + junit + junit + 4.13.2 + test + pl.psnc.dl.ege ege-framework @@ -65,7 +72,7 @@ - github + githubedirom GitHub Edirom Apache Maven Packages https://maven.pkg.github.com/edirom/lilypond-converter diff --git a/required.sh b/required.sh new file mode 100644 index 0000000..8356feb --- /dev/null +++ b/required.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# installs lilypond into /usr/local/lilypond and /usr/local/bin as shortcut +curl -o /tmp/lilypond.sh https://lilypond.org/download/binaries/linux-64/lilypond-2.20.0-1.linux-64.sh +chmod a+x /tmp/lilypond.sh && /tmp/lilypond.sh --batch diff --git a/src/main/java/de/edirom/meigarage/lilypond/LilyPondConverter.java b/src/main/java/de/edirom/meigarage/lilypond/LilyPondConverter.java index e029c1c..f869b21 100644 --- a/src/main/java/de/edirom/meigarage/lilypond/LilyPondConverter.java +++ b/src/main/java/de/edirom/meigarage/lilypond/LilyPondConverter.java @@ -27,8 +27,12 @@ public class LilyPondConverter implements Converter { protected static final String LILYPOND_VERSION = "2.20.0"; + public void convert(InputStream inputStream, OutputStream outputStream, ConversionActionArguments conversionDataTypes) throws ConverterException, IOException{ + convert(inputStream,outputStream,conversionDataTypes, null); + } + public void convert(InputStream inputStream, OutputStream outputStream, - ConversionActionArguments conversionDataTypes) + ConversionActionArguments conversionDataTypes, String tempDir) throws ConverterException, IOException { boolean found = false; @@ -44,7 +48,7 @@ public void convert(InputStream inputStream, OutputStream outputStream, + conversionDataTypes.getOutputType().toString() + " WITH profile " + profile ); convertDocument(inputStream, outputStream, cadt.getInputType(), cadt.getOutputType(), - cadt.getProperties()); + cadt.getProperties(), tempDir); found = true; } } @@ -59,7 +63,7 @@ public void convert(InputStream inputStream, OutputStream outputStream, * Prepares transformation : based on MIME type. */ private void convertDocument(InputStream inputStream, OutputStream outputStream, - DataType fromDataType, DataType toDataType, Map properties) throws IOException, + DataType fromDataType, DataType toDataType, Map properties, String tempDir) throws IOException, ConverterException { // LilyPond to PDF @@ -67,7 +71,7 @@ private void convertDocument(InputStream inputStream, OutputStream outputStream, toDataType.getFormat().equals(Conversion.LILYPONDTOPDF.getOFormatId())) { properties.put("extension", "pdf"); - performLilyPondTransformation(inputStream, outputStream, "pdf", properties); + performLilyPondTransformation(inputStream, outputStream, "pdf", properties, tempDir); } // LilyPond to PNG @@ -75,17 +79,17 @@ else if(fromDataType.getFormat().equals(Conversion.LILYPONDTOPNG.getIFormatId()) toDataType.getFormat().equals(Conversion.LILYPONDTOPNG.getOFormatId())) { properties.put("extension", "png"); - performLilyPondTransformation(inputStream, outputStream, "png", properties); + performLilyPondTransformation(inputStream, outputStream, "png", properties, tempDir); } } private void performLilyPondTransformation(InputStream inputStream, OutputStream outputStream, String format, - Map properties) throws IOException, ConverterException { + Map properties, String tempDir) throws IOException, ConverterException { File inTmpDir = null; File outTempDir = null; try { - inTmpDir = prepareTempDir(); + inTmpDir = prepareTempDir(tempDir); ior.decompressStream(inputStream, inTmpDir); // avoid processing files ending in .bin File inputFile = searchForData(inTmpDir, "^.*(?