Skip to content

Commit

Permalink
Merge pull request #167 from spdx/issue164
Browse files Browse the repository at this point in the history
Copy license XML files to output directory
  • Loading branch information
goneall authored Jun 3, 2023
2 parents 8cd690f + c1daac0 commit 6ee240c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
<profiles>
<profile>
Expand Down
9 changes: 9 additions & 0 deletions src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Map.Entry;
import java.util.Set;

import org.apache.commons.io.FileUtils;
import org.spdx.crossref.CrossRefHelper;
import org.spdx.library.InvalidSPDXAnalysisException;
import org.spdx.library.model.license.LicenseException;
Expand Down Expand Up @@ -79,6 +80,7 @@
* - RDF XML - RDF XML format defined by the SPDX Spec
* - RDF Turtle - RDF Turtle format defined by the SPDX Spec
* - Website - the content for the website available at https://spdx.org/licenses
* - license-list-XML - A copy of the input license XML file(s)
*
* Output generated by this tool can be found at https://github.com/spdx/license-list-data and on the
* spdx.org licenses website
Expand Down Expand Up @@ -119,6 +121,7 @@ public class LicenseRDFAGenerator {
private static final String RDFNT_FOLDER_NAME = "rdfnt";
private static final String TABLE_OF_CONTENTS_FILE_NAME = "licenses.md";
private static final String RDF_JSON_LD_FOLDER_NAME = "jsonld";
private static final String LICENSE_XML_FOLDER_NAME = "license-list-XML";
private static final String ENV_USE_SYSTEM_TEST = "USE_TEST_FOR_TEXT";

/**
Expand Down Expand Up @@ -248,10 +251,16 @@ public static List<String> generateLicenseData(File licenseXml, File dir,
List<ILicenseFormatWriter> writers = Lists.newArrayList();
ISpdxListedLicenseProvider licenseProvider = null;
try {
File licenseXmlOutputFolder = new File(dir.getPath() + File.separator + LICENSE_XML_FOLDER_NAME);
if (!licenseXmlOutputFolder.isDirectory() && !licenseXmlOutputFolder.mkdir()) {
throw new LicenseGeneratorException("Error: license-xml folder is not a directory");
}
if (licenseXml.isDirectory()) {
licenseProvider = new XmlLicenseProviderWithCrossRefDetails(licenseXml);
FileUtils.copyDirectory(licenseXml, licenseXmlOutputFolder);
} else {
licenseProvider = new XmlLicenseProviderSingleFile(licenseXml);
Files.copy(licenseXml, new File(licenseXmlOutputFolder.getAbsolutePath() + File.separator + licenseXml.getName()));
}
File textFolder = new File(dir.getPath() + File.separator + TEXT_FOLDER_NAME);
if (!textFolder.isDirectory() && !textFolder.mkdir()) {
Expand Down

0 comments on commit 6ee240c

Please # to comment.