-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write Excel files with extensive License Information (inc. infos from…
… the JARs) (#527) Co-authored-by: Jan-Hendrik Diederich <[email protected]> Co-authored-by: Jan-Hendrik Diederich <[email protected]> Co-authored-by: Jan Diederich <[email protected]>
- Loading branch information
1 parent
6b6e0e6
commit fe0747a
Showing
31 changed files
with
3,665 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/it/aggregate-download-licenses-extended-spreadsheet/child1/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
#%L | ||
License Maven Plugin | ||
%% | ||
Copyright (C) 2008 - 2011 CodeLutin, Codehaus, 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 | ||
<http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
#L% | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.codehaus.mojo.license.test</groupId> | ||
<artifactId>test-aggregate-download-licenses-extended-excel</artifactId> | ||
<version>@project.version@</version> | ||
</parent> | ||
<artifactId>test-aggregate-download-licenses-extended-spreadsheet-child1</artifactId> | ||
|
||
<name>License Test :: aggregate-download-licenses - Extended Spreadsheet — child 1</name> | ||
|
||
<dependencies> | ||
|
||
<!-- use license 'The Apache Software License, Version 2.0' --> | ||
<dependency> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
<version>1.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jdt</groupId> | ||
<artifactId>org.eclipse.jdt.core</artifactId> | ||
<version>3.35.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> | ||
|
||
|
64 changes: 64 additions & 0 deletions
64
src/it/aggregate-download-licenses-extended-spreadsheet/child2/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
#%L | ||
License Maven Plugin | ||
%% | ||
Copyright (C) 2008 - 2011 CodeLutin, Codehaus, 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 | ||
<http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
#L% | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.codehaus.mojo.license.test</groupId> | ||
<artifactId>test-aggregate-download-licenses-extended-excel</artifactId> | ||
<version>@project.version@</version> | ||
</parent> | ||
<artifactId>test-aggregate-download-licenses-extended-spreadsheet-child2</artifactId> | ||
|
||
<name>License Test :: aggregate-download-licenses - Extended Spreadsheet — child 2</name> | ||
|
||
<dependencies> | ||
|
||
<!-- use license 'Apache License, Version 2.0' --> | ||
<dependency> | ||
<groupId>com.jhlabs</groupId> | ||
<artifactId>filters</artifactId> | ||
<version>2.0.235</version> | ||
</dependency> | ||
|
||
<!-- use license 'Apache Public License 2.0' --> | ||
<dependency> | ||
<groupId>org.sonatype.plexus</groupId> | ||
<artifactId>plexus-cipher</artifactId> | ||
<version>1.7</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.10.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> | ||
|
||
|
23 changes: 23 additions & 0 deletions
23
src/it/aggregate-download-licenses-extended-spreadsheet/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
### | ||
# #%L | ||
# License Maven Plugin | ||
# %% | ||
# Copyright (C) 2008 - 2011 CodeLutin, Codehaus, 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 | ||
# <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
# #L% | ||
### | ||
invoker.goals=clean license:aggregate-download-licenses | ||
invoker.failureBehavior=fail-fast |
77 changes: 77 additions & 0 deletions
77
src/it/aggregate-download-licenses-extended-spreadsheet/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
#%L | ||
License Maven Plugin | ||
%% | ||
Copyright (C) 2008 - 2011 CodeLutin, Codehaus, 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 | ||
<http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
#L% | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.codehaus.mojo.license.test</groupId> | ||
<artifactId>test-aggregate-download-licenses-extended-excel</artifactId> | ||
<version>@project.version@</version> | ||
|
||
<modules> | ||
<module>child1</module> | ||
<module>child2</module> | ||
</modules> | ||
|
||
<name>License Test :: aggregate-download-licenses - Extended Spreadsheet</name> | ||
|
||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<license.verbose>true</license.verbose> | ||
</properties> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>license-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<extendedInfo>true</extendedInfo> | ||
<writeCalcFile>true</writeCalcFile> | ||
<writeExcelFile>true</writeExcelFile> | ||
<licenseMerges> | ||
<licenseMerge>The Apache Software License, Version 2.0|Apache License, Version 2.0|Apache Public License | ||
2.0 | ||
</licenseMerge> | ||
</licenseMerges> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.sonarsource.sonarlint.core</groupId> | ||
<artifactId>sonarlint-core</artifactId> | ||
<version>9.2.0.74516</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
86 changes: 86 additions & 0 deletions
86
src/it/aggregate-download-licenses-extended-spreadsheet/postbuild.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* #%L | ||
* License Maven Plugin | ||
* %% | ||
* Copyright (C) 2008 - 2011 CodeLutin, Codehaus, 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 | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
|
||
import org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument | ||
import org.odftoolkit.odfdom.doc.table.OdfTable | ||
|
||
import java.util.logging.Level | ||
import java.util.logging.Logger | ||
|
||
import org.apache.poi.ss.usermodel.Cell | ||
import org.apache.poi.ss.usermodel.CellType | ||
import org.apache.poi.ss.usermodel.Row | ||
import org.apache.poi.ss.usermodel.Sheet | ||
import org.apache.poi.ss.usermodel.Workbook | ||
import org.apache.poi.ss.usermodel.WorkbookFactory | ||
|
||
log = Logger.getLogger("test-aggregate-download-licenses-extended-spreadsheet") | ||
|
||
static boolean searchTextInExcel(Sheet sheet, String searchText) { | ||
def log2 = Logger.getLogger("test-aggregate-download-licenses-extended-spreadsheet-search") | ||
|
||
for (Iterator<Row> rowIterator = sheet.rowIterator(); rowIterator.hasNext();) { | ||
Row row = rowIterator.next() | ||
for (Iterator<Cell> cellIterator = row.cellIterator(); cellIterator.hasNext();) { | ||
Cell cell = cellIterator.next() | ||
if (cell.cellType == CellType.STRING || cell.cellType == CellType.BLANK) { | ||
def cellValue = cell.stringCellValue | ||
if (cellValue == searchText) { | ||
return true | ||
} else { | ||
log2.log(Level.FINEST, "Cell Value: {0}", cellValue) | ||
} | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
// -------------- Excel ---------------------- | ||
excelFile = new File(basedir, 'target/generated-resources/licenses.xlsx') | ||
assert excelFile.exists() | ||
assert excelFile.length() > 100 | ||
|
||
try (InputStream input = new FileInputStream(excelFile)) { | ||
// So it can be easily opened and inspected manually. In a modern IDE it's just a (double-)click in the log output. | ||
log.log(Level.FINE, "Excel export at: {}", excelFile.absolutePath) | ||
Workbook workbook = WorkbookFactory.create(input) | ||
Sheet sheet = workbook.getSheetAt(0) | ||
|
||
assert searchTextInExcel(sheet, "Maven information") | ||
assert searchTextInExcel(sheet, "The Apache Software License, Version 2.0") | ||
assert searchTextInExcel(sheet, "The Apache Software Foundation") | ||
} | ||
|
||
// -------------- Calc ----------------- | ||
|
||
calcFile = new File(basedir, 'target/generated-resources/licenses.ods') | ||
assert calcFile.exists() | ||
assert calcFile.length() > 100 | ||
|
||
try (OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.loadDocument(calcFile)) { | ||
// So it can be easily opened and inspected manually. In a modern IDE it's just a (double-)click in the log output. | ||
log.log(Level.FINE, "Calc export at: {}", calcFile.absolutePath) | ||
List<OdfTable> tableList = spreadsheet.getTableList() | ||
OdfTable table = tableList.get(0) | ||
assert table.getRowCount() >= 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.