lunes, 3 de mayo de 2021

Crear una libreria jar con Maven que incluya recursos.

Se ha seguido a Mkyong 

La madre del cordero está en el pom.xml

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>openadmin</groupId>
	<artifactId>daobaselogann</artifactId>
	<packaging>jar</packaging>
	<version>1.00</version>
	<name>DaoBaseLogAnnot</name>
	<description>DAO Base and Log</description>


	<properties>

		<maven.compiler.source>16</maven.compiler.source> <!-- 15,13,12 -->
		<maven.compiler.target>16</maven.compiler.target> <!-- 15,13, 12 -->

		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

		<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>

		<lombok.version>1.18.20</lombok.version><!-- 1.18.18, 1.18.12 -->
		<jackson.version>2.11.4</jackson.version> <!-- NO va->2.12.1, OK Antes 2.10.2, 2.10.0, 2.9.8 -->

		<commons-io.version>2.8.0</commons-io.version>
		<lang3.version>3.11</lang3.version> <!-- OK Antes 3.9 -->

		<hibernate.version>5.4.27.Final</hibernate.version>  <!-- 5.4.21.Final, 5.4.16.Final, 5.2.16, 5.4.5 -->
		<hibernate-validator.version>6.2.0.Final</hibernate-validator.version><!-- 
			6.1.5.Final -->

		<h2.version>1.4.200</h2.version><!-- 1.4.199 -->
		<postgresql.version>42.2.18</postgresql.version> <!-- (1.1)42.2.14 -->
		<jtds.version>1.3.1</jtds.version>


	</properties>

	<dependencies>

		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>${lombok.version}</version>
			<scope>provided</scope>
		</dependency>




		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>${hibernate.version}</version>
		</dependency>

		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-envers</artifactId>
			<version>${hibernate.version}</version>
		</dependency>

		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-testing</artifactId>
			<version>${hibernate.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-validator</artifactId>
			<version>${hibernate-validator.version}</version>
		</dependency>

		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>${jackson.version}</version>
		</dependency>

		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-yaml</artifactId>
			<version>${jackson.version}</version>
		</dependency>

		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-xml</artifactId>
			<version>${jackson.version}</version>
		</dependency>

		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>${commons-io.version}</version>
		</dependency>

		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>${lang3.version}</version>
		</dependency>

	</dependencies>

	<!-- BEGIN ADD -->
	<build>
		<finalName>daoedu</finalName>
		<plugins>

			<!-- download source code in Eclipse, best practice -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<version>2.10</version>
				<configuration>
					<downloadSources>true</downloadSources>
					<downloadJavadocs>false</downloadJavadocs>
				</configuration>
			</plugin>

			<!-- Set a compiler level -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.1</version>
				<configuration>
					<source>${maven.compiler.source}</source>
					<target>${maven.compiler.target}</target>
				</configuration>
			</plugin>

			<!-- Maven Shade Plugin -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.2.4</version>
				<executions>
					<!-- Run shade goal on package phase -->
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<!-- <configuration> <transformers> -->
						<!-- add Main-Class to manifest file -->
						<!-- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
							<mainClass>com.mkyong.core.utils.App</mainClass> </transformer> </transformers> 
							</configuration> -->
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>

</project>
  


La parte build (que está en negrilla) permite crear el jar.
No indicamos ninguna clase para el "main"
Ejecutamos RunAs-Maven Build... y le damos a goals: package
Y nos genera en la carpeta "target" los ficheros daoedu.jar (que se lo hemos indicado en la línea 111), y también el fichero (que de momento no gastaremso original-daoedu.jar






No hay comentarios :

Publicar un comentario