gpt4 book ai didi

java - 如何正确构建java maven项目的jar文件?

转载 作者:行者123 更新时间:2023-11-30 02:39:50 25 4
gpt4 key购买 nike

这是我的 POM 文件

<?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.tacton.tcsite</groupId>
<artifactId>asdf</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<description>Plugin provides testing for my first application</description>
<name>Hello World Application</name>



<properties>
<outputDir>${project.build.directory}/output</outputDir>
<profileName>tcsite-deploy</profileName>
<tcsite.deploy.dir>C:/Program Files/TCsite standard 3.4.1/tomcat/webapps/ROOT/WEB-INF/plugins</tcsite.deploy.dir>

<!-- Add custom build final name-->
<plugin.finalName>${project.artifactId}.${project.version} </plugin.finalName>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>

<build>
<finalName>${plugin.finalName}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>tcsite-repository-releases</id>
<name>tcsite-repository-releases</name>
<url>http://artifactory.tacton.com/artifactory/tcsite</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<profiles>
<profile>
<id>tcsite-deploy</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>tcsite-deploy-dir</name>
<value>${tcsite.deploy.dir}</value>
</property>
</activation>
<build>
<finalName>${plugin.finalName}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath"/>
<if>
<!-- Remember to set -DSKIP_DEPLOY=true in Jenkins Build Job configuration in order
to ignore copying the file to ${tcsite.deploy.dir} -->
<!-- TISD-1405 -->
<isfalse value="${SKIP_DEPLOY}"/>
<then>
<copy
file="${project.build.directory}/${project.build.finalName}.${project.packaging}"
todir="${tcsite.deploy.dir}" verbose="true"
failonerror="false"/>
</then>
</if>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<testSources>
<source>
<directory>${project.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</source>
</testSources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

这是我的目录结构

enter image description here

问题是当我用maven构建它时。它创建了 jar 文件,但该 jar 文件不包含插件目录中的文件。 helloWorld.js 和plugin.xml 。这个问题将如何解决?

最佳答案

Maven 无法将 src/main/plugin 文件夹识别为源或资源文件夹。
只需将插件文件夹移动到 Maven 中的默认资源目录 src/main/resources 即可解决您的问题。

关于java - 如何正确构建java maven项目的jar文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42090481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com