Skip to content

Commit

Permalink
update pom
Browse files Browse the repository at this point in the history
  • Loading branch information
Joabsonlg committed Jan 7, 2025
1 parent 571763c commit 8bd1bac
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 1 deletion.
103 changes: 102 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,34 @@

<groupId>io.github.joabsonlg</groupId>
<artifactId>pdf-builder</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>PDF Builder</name>
<description>A high-level PDF generation library built on top of Apache PDFBox</description>
<url>https://github.com/Joabsonlg/pdf-builder</url>

<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>

<developers>
<developer>
<id>joabsonlg</id>
<name>Joabson Arley do Nascimento</name>
<email>[email protected]</email>
<url>https://github.com/joabsonlg</url>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/Joabsonlg/pdf-builder.git</connection>
<developerConnection>scm:git:ssh://[email protected]:Joabsonlg/pdf-builder.git</developerConnection>
<url>https://github.com/Joabsonlg/pdf-builder</url>
</scm>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down Expand Up @@ -152,6 +175,84 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
24 changes: 24 additions & 0 deletions release.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#release configuration
#Tue Jan 07 13:49:05 BRT 2025
projectVersionPolicyId=default
project.scm.io.github.joabsonlg\:pdf-builder.developerConnection=scm\:git\:ssh\://[email protected]\:Joabsonlg/pdf-builder.git
scm.rollbackCommitComment=@{prefix} rollback the release of @{releaseLabel}
remoteTagging=true
scm.commentPrefix=[maven-release-plugin]
releaseStrategyId=default
project.scm.io.github.joabsonlg\:pdf-builder.connection=scm\:git\:https\://github.com/Joabsonlg/pdf-builder.git
scm.branchCommitComment=@{prefix} prepare branch @{releaseLabel}
pinExternals=false
project.scm.io.github.joabsonlg\:pdf-builder.tag=HEAD
completedPhase=check-poms
scm.url=scm\:git\:ssh\://[email protected]\:Joabsonlg/pdf-builder.git
scm.developmentCommitComment=@{prefix} prepare for next development iteration
projectVersionPolicyConfig=<projectVersionPolicyConfig>${projectVersionPolicyConfig}</projectVersionPolicyConfig>\n
scm.tagNameFormat=@{project.artifactId}-@{project.version}
exec.activateProfiles=gpg
pushChanges=true
exec.snapshotReleasePluginAllowed=false
preparationGoals=clean verify
project.scm.io.github.joabsonlg\:pdf-builder.url=https\://github.com/Joabsonlg/pdf-builder
scm.releaseCommitComment=@{prefix} prepare release @{releaseLabel}
exec.pomFileName=pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package io.github.joabsonlg.pdfbuilder.core;

import io.github.joabsonlg.pdfbuilder.components.logo.LogoStyle;

import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.Path;

import static org.junit.jupiter.api.Assertions.assertTrue;

@DisplayName("PDFBuilder")
class PDFBuilderTest {

private PDFBuilder pdfBuilder;
private PDDocument document;

@BeforeEach
void setUp() {
document = new PDDocument();
pdfBuilder = PDFBuilder.create();
}

@AfterEach
void tearDown() throws IOException {
document.close();
}

@Test
@DisplayName("Deve adicionar logo com imagens esquerda e direita")
void shouldAddLogoWithLeftAndRightImages(@TempDir Path tempDir) throws IOException {
// Criar imagens temporárias para teste
Path leftImagePath = tempDir.resolve("left-logo.png");
Path rightImagePath = tempDir.resolve("right-logo.png");
createTestImage(leftImagePath);
createTestImage(rightImagePath);

LogoStyle style = LogoStyle.builder().build();
pdfBuilder.setLogo("Test Logo", style, leftImagePath.toString(), rightImagePath.toString());
pdfBuilder.addNewPage(); // Adiciona uma página para o logo ser renderizado
PDPage page = pdfBuilder.getDocument().getPage(0);

// Verifica se o número de XObjects (imagens) é 2
long numberOfXObjects = 0;
for (COSName ignored : page.getResources().getXObjectNames()) {
numberOfXObjects++;
}
assertTrue(numberOfXObjects == 2, "Deveriam existir 2 imagens de logo (esquerda e direita).");
}

/**
* Cria uma imagem de teste no caminho especificado.
*
* @param path Caminho onde a imagem será criada
* @throws IOException se houver erro ao criar a imagem
*/
private void createTestImage(Path path) throws IOException {
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, 100, 100);
g2d.dispose();
ImageIO.write(image, "PNG", path.toFile());
}
}

0 comments on commit 8bd1bac

Please sign in to comment.