Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

Tuesday, May 3, 2016

How to show java web project version using Maven

1. Pom.xml


<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>

<plugin>
<artifactId>maven-war-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.1.1</version>
<configuration>
<archive>
<manifestEntries>
<SCM-Revision>${maven.build.timestamp}</SCM-Revision>
</manifestEntries>
</archive>
</configuration>

</plugin>

2. Java code.

public static String getProjectVersion() {
ServletContext application = Sessions.getCurrent().getWebApp().getServletContext();
InputStream inputStream = application.getResourceAsStream("/META-INF/MANIFEST.MF");
Manifest manifest;
try {
manifest = new Manifest(inputStream);
Attributes attr = manifest.getMainAttributes();
return attr.getValue("SCM-Revision");
} catch (IOException e) {
e.printStackTrace();
}
return "";
}


Monday, August 31, 2015

MAVEN plugin for pom.xml

1. Tomcat start with mvn command.

 <plugin>
<groupid>org.apache.tomcat.maven</groupid>
<artifactid>tomcat7-maven-plugin</artifactid>
<version>2.2</version>
</plugin>

command: 
mvn tomcat7:run


2. For compile sleeted java version.

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

3. For avoiding Dwtpversion=2.0
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
Before :
mvn eclipse:eclipse --> Eclipse Java project (JAR)
mvn eclipse:eclipse -Dwtpversion=2.0 --> Eclipse Java web project (WAR)

Now:
mvn eclipse:eclipse --> Eclipse Java web project

How ChatGPT can Benefit Coding: Your Guide to Leveraging an AI Language Model

 Introduction: Hello, coders! Welcome to this blog post on how ChatGPT, an AI language model, can benefit your coding skills and projects. A...