具有依赖性的Maven构建缺少自己的jar

时间:2016-05-24 17:58:50

标签: maven jasper-reports maven-assembly-plugin

我有Netbeans Maven项目。我创建了自己的字体jar文件,因为Jasper Reports不支持Cp1257。我已经将我的jar安装到本地maven repo,通过add依赖添加了依赖。在Netbeans中运行时我没有任何问题 - 报告是使用依赖声明的字体创建的,并正确导出为PDF,但在使用maven程序集插件创建可执行jar之后,看起来我的依赖关系会以某种方式消失或变得无法访问,因为。我在Netbeans Maven项目的依赖列表中看到了我的字体文件。如果您需要更多代码或smth,请告诉我我将添加所需的代码。 提前谢谢。

jasperreports_extension.properties

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory`
net.sf.jasperreports.extension.simple.font.families.ireportfamily1463309406404=fonts/fontsfamily1463309406404.xml

fontsfamily1463309406404.xml

<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
   <fontFamily name="Times New Roman">
       <normal><![CDATA[fonts/times.ttf]]></normal>
       <bold><![CDATA[fonts/timesbd.ttf]]></bold>
       <italic><![CDATA[fonts/timesbi.ttf]]></italic>
       <boldItalic><![CDATA[fonts/timesi.ttf]]></boldItalic>
       <pdfEncoding><![CDATA[Cp1257]]></pdfEncoding>
       <pdfEmbedded><![CDATA[true]]></pdfEmbedded>
   </fontFamily>
</fontFamilies>

CLASS

StyleBuilder plainStyle = DynamicReports.stl.style().setFontName("Times New Roman");

的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <groupId>com.mycompany</groupId>
    <artifactId>MYAPPNAME</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <repositories>
</repositories>
    <dependencies>
...
<dependency>
            <groupId>my.fonts</groupId>
            <artifactId>fonts2</artifactId>
            <version>1.1</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>forms.Login</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>create-my-bundle</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>   
        </plugins>
    </build>
    <name>MYAPPNAME</name>
</project>

0 个答案:

没有答案