-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tgz option to iTools packager Maven plugin (#3170)
* Add tgz option to packager * Tgz packaging handles large ids correctly Signed-off-by: Guillaume Verger <[email protected]> Co-authored-by: jeandemanged <[email protected]> Co-authored-by: Olivier Perrin <[email protected]>
- Loading branch information
Showing
7 changed files
with
211 additions
and
3 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
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
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
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
82 changes: 82 additions & 0 deletions
82
itools-packager/src/test/java/com/powsybl/itools/ItoolsPackagerMojoTest.java
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,82 @@ | ||
/** | ||
* Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.itools; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.apache.maven.execution.DefaultMavenExecutionRequest; | ||
import org.apache.maven.execution.MavenExecutionRequest; | ||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.plugin.MojoExecution; | ||
import org.apache.maven.plugin.testing.AbstractMojoTestCase; | ||
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.project.ProjectBuilder; | ||
import org.apache.maven.project.ProjectBuildingRequest; | ||
import org.codehaus.plexus.configuration.DefaultPlexusConfiguration; | ||
import org.codehaus.plexus.configuration.PlexusConfiguration; | ||
import org.eclipse.aether.DefaultRepositorySystemSession; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* @author Damien Jeandemange {@literal <damien.jeandemange at artelys.com>} | ||
*/ | ||
public class ItoolsPackagerMojoTest extends AbstractMojoTestCase { | ||
|
||
private static final File BASEDIR = new File("src/test/resources/test-maven-project/"); | ||
private static final File POM_XML = new File(BASEDIR, "pom.xml"); | ||
private static final File TARGET = new File(BASEDIR, "target"); | ||
public static final String DEFAULT_PACKAGE_NAME = "itools-packager-test-project-1.0.0-SNAPSHOT"; | ||
|
||
ItoolsPackagerMojo mojo; | ||
PlexusConfiguration configuration; | ||
|
||
@Override | ||
protected void setUp() | ||
throws Exception { | ||
// required | ||
super.setUp(); | ||
MavenProject project = readMavenProject(); | ||
MavenSession session = newMavenSession(project); | ||
MojoExecution execution = newMojoExecution("package-zip"); | ||
mojo = (ItoolsPackagerMojo) lookupConfiguredMojo(session, execution); | ||
configuration = new DefaultPlexusConfiguration("configuration"); | ||
} | ||
|
||
@Override | ||
protected void tearDown() | ||
throws Exception { | ||
// required | ||
super.tearDown(); | ||
FileUtils.deleteDirectory(TARGET); // cleanup | ||
} | ||
|
||
protected MavenProject readMavenProject() throws Exception { | ||
MavenExecutionRequest request = new DefaultMavenExecutionRequest(); | ||
request.setBaseDirectory(BASEDIR); | ||
ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest(); | ||
projectBuildingRequest.setRepositorySession(new DefaultRepositorySystemSession()); | ||
MavenProject project = lookup(ProjectBuilder.class).build(POM_XML, projectBuildingRequest).getProject(); | ||
assertNotNull(project); | ||
return project; | ||
} | ||
|
||
public void testDefaultConfiguration() throws Exception { | ||
super.configureMojo(mojo, configuration); | ||
assertNotNull(mojo); | ||
mojo.execute(); | ||
assertTrue(new File(TARGET, DEFAULT_PACKAGE_NAME + ".zip").exists()); | ||
} | ||
|
||
public void testPackageTypeTgz() throws Exception { | ||
configuration.addChild("packageType", "tgz"); | ||
super.configureMojo(mojo, configuration); | ||
assertNotNull(mojo); | ||
mojo.execute(); | ||
assertTrue(new File(TARGET, DEFAULT_PACKAGE_NAME + ".tgz").exists()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
itools-packager/src/test/resources/test-maven-project/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,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/) | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
SPDX-License-Identifier: MPL-2.0 | ||
--> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<packaging>pom</packaging> | ||
<groupId>com.powsybl</groupId> | ||
<artifactId>itools-packager-test-project</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>powsybl-itools-packager-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>package-zip</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
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