Maven: Unterschied zwischen den Versionen

Aus Tutorials
Zur Navigation springen Zur Suche springen
 
(12 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 9: Zeile 9:


== Profile ==
== Profile ==
=== Properties ===
<pre>
<project>
...
<profiles>
<profile>
<id>profile1</id>
<properties>
<property-xy>value-xy</property-xy>
</properties>
</profile>
<profile>
<id>profile1</id>
<properties>
<property-xy>value-xy</property-xy>
</properties>
</profile>
</profiles>
...
<build>
...
<!-- filtering is disabled by default -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
</project>
</pre>
=== Build ===


<pre>
<pre>
Zeile 18: Zeile 62:
<pre>
<pre>
mvn install -X
mvn install -X
</pre>
== Unit-Tests ==
Kompilieren ohne Unit-Tests:
<pre>
mvn clean install -Dmaven.test.skip=true
</pre>
== SQL-Maven-Plugin ==
=== Kommandozeilenaufruf ===
<pre>
mvn org.codehaus.mojo:sql-maven-plugin:execute
</pre>
== Surfire-Maven-Plugin (JUnit) ==
[https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html]
== JOOQ-Maven-Plugin ==
=== Kommandozeilenaufruf ===
<pre>
mvn org.jooq:jooq-codegen-maven:generate
</pre>
</pre>


Zeile 25: Zeile 97:
mvn dependency:tree
mvn dependency:tree
</pre>
</pre>
== Deploy to Tomcat ==
[[Deploy to Tomcat (Maven)|Deploy to Tomcat]]


== Warnungen / Errors ==
== Warnungen / Errors ==
Zeile 75: Zeile 151:
</project>
</project>
</pre>
</pre>
== Multimodule Maven Project ==
[[Multimodule Maven Project]]


== Repository ==
== Repository ==

Aktuelle Version vom 29. Oktober 2021, 14:26 Uhr

Pfade

Windows

JAVA_HOME = <path to jdk>
M2_HOME = <path to maven>

Profile

Properties

<project>
	...

	<profiles>
		<profile>
			<id>profile1</id>
			<properties>
				<property-xy>value-xy</property-xy>
			</properties>
		</profile>

		<profile>
			<id>profile1</id>
			<properties>
				<property-xy>value-xy</property-xy>
			</properties>
		</profile>
	</profiles>

	...

	<build>
		...

	
		<!-- filtering is disabled by default -->
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
		</resources>

		...

	</build>
</project>

Build

mvn install -P <profil1>[,<profile2>]

Debugging

mvn install -X

Unit-Tests

Kompilieren ohne Unit-Tests:

mvn clean install -Dmaven.test.skip=true

SQL-Maven-Plugin

Kommandozeilenaufruf

mvn org.codehaus.mojo:sql-maven-plugin:execute

Surfire-Maven-Plugin (JUnit)

https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html

JOOQ-Maven-Plugin

Kommandozeilenaufruf

mvn org.jooq:jooq-codegen-maven:generate

Abhängigkeiten anzeigen

mvn dependency:tree

Deploy to Tomcat

Deploy to Tomcat

Warnungen / Errors

[WARNING] Using platform encoding (windows-1252 actually) to copy filtered resources, i.e. build is platform dependent!

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.7</version>
        <configuration>
          ...
          <encoding>UTF-8</encoding>
          ...
        </configuration>
      </plugin>
    </plugins>
    ...
  </build>
  ...
</project>

Failed to deploy artifacts/metadata: No connector available to access repository

Mit Maven 3 werden standardmäßig nur ftp, http und https als Protokoll unterstützt. Andere Protokolle, wie z.B. dav benötigen eine Erweiterung für das jeweilige Protokoll:

<project>
  ...
  <build>
    ...
    <extensions>
      <!-- Enabling the use of WebDAV -->
        <extension>
          <groupId>org.apache.maven.wagon</groupId>
          <artifactId>wagon-webdav-jackrabbit</artifactId>
          <version>2.10</version>
        </extension>
      </extensions>
    ...
  </build>
  ...
</project>

Multimodule Maven Project

Multimodule Maven Project

Repository

https://mvnrepository.com/


Zurück zu Java