I'm new to maven and servlets but I'm absolutely at my wits end. It refuses to work at every single twist and turn and for some reason it says "Nothing to compile - all classes are up to date" eventhough I've changed everything there is to change.
This is my servlet:
#WebServlet("/HelloWorld")
public class HelloWorldServlet extends HttpServlet {
#Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
String hold = request.getParameter("text");
try(PrintWriter out = response.getWriter()) {
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<body>");
out.println("<p>"+hold+"</p>");
out.println("</body>");
out.println("</html>");
}
}
}
This is my pom.xml:
<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>pxl.kits</groupId>
<artifactId>Webcomponents</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.12</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<type>installed</type>
<home>${env.TOMCAT_HOME}</home>
</container>
<configuration>
<type>existing</type>
<home>${env.TOMCAT_HOME}</home>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
And the command I use to run/debug:
mvn package cargo:deploy
Edit:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Webcomponents 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Webcomponents ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) #Webcomponents -
--
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources)#Webcomponents ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) #Webcomponents ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Webcomponents ---
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # Webcomponents ---
[INFO] Packaging webapp
[INFO] Assembling webapp [Webcomponents] in [C:\Users\Laurens\workspace\Webcompo
nents\target\Webcomponents-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Laurens\workspace\Webcomponents\src\ma
in\webapp]
[INFO] Webapp assembled in [41 msecs]
[INFO] Building war: C:\Users\Laurens\workspace\Webcomponents\target\Webcomponen
ts-0.0.1-SNAPSHOT.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- cargo-maven2-plugin:1.4.12:deploy (default-cli) # Webcomponents ---
[INFO] [edDeployerDeployMojo] Resolved container artifact org.codehaus.cargo:car
go-core-container-tomcat:jar:1.4.12 for container tomcat8x
[INFO] [stalledLocalDeployer] Deploying [C:\Users\Laurens\workspace\Webcomponent
s\target\Webcomponents-0.0.1-SNAPSHOT.war] to [C:\apache-tomcat-8.0.35/webapps].
..
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.063 s
[INFO] Finished at: 2016-06-01T16:15:00+02:00
[INFO] Final Memory: 12M/200M
[INFO] ------------------------------------------------------------------------
Related
For starters, I have not worked with Maven much at all.
I had everything working except for the version not being specified, but when I did specify the Maven version in the pom.xml, it still didn't work.
Note: Every run showed "Build Success" but none put a completed jar file in the target folder, which is what I thought should have happened.
Here is my output from eclipse:
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< TromboneSMP:VoluntaryPullFromEternity >----------------
[INFO] Building VoluntaryPullFromEternity 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # VoluntaryPullFromEternity ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) # VoluntaryPullFromEternity ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\Roboverse\eclipse-workspace\VoluntaryPullFromEternity\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # VoluntaryPullFromEternity ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) # VoluntaryPullFromEternity ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # VoluntaryPullFromEternity ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # VoluntaryPullFromEternity ---
[INFO] Building jar: C:\Users\Roboverse\eclipse-workspace\VoluntaryPullFromEternity\target\VoluntaryPullFromEternity-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # VoluntaryPullFromEternity ---
[INFO] Installing C:\Users\Roboverse\eclipse-workspace\VoluntaryPullFromEternity\target\VoluntaryPullFromEternity-0.0.1-SNAPSHOT.jar to C:\Users\Roboverse\.m2\repository\TromboneSMP\VoluntaryPullFromEternity\0.0.1-SNAPSHOT\VoluntaryPullFromEternity-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\Roboverse\eclipse-workspace\VoluntaryPullFromEternity\pom.xml to C:\Users\Roboverse\.m2\repository\TromboneSMP\VoluntaryPullFromEternity\0.0.1-SNAPSHOT\VoluntaryPullFromEternity-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.045 s
[INFO] Finished at: 2021-03-01T18:46:45-05:00
[INFO] ------------------------------------------------------------------------
Here is my pom.xml:
<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>TromboneSMP</groupId>
<artifactId>VoluntaryPullFromEternity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version><!--change this value depending on the version-->
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
The output says
Building jar: C:\Users\Roboverse\eclipse-workspace\VoluntaryPullFromEternity\target\VoluntaryPullFromEternity-0.0.1-SNAPSHOT.jar
So if you do not see a JAR in target, you probably need to refresh your Eclipse. Have a look in the Windows Explorer (or some Linux equivalent) if you can find the file.
I have been trying to pack the properties file inside my jar using Maven but no luck so far.
Project Structure:
src/main/java
All java source files
src/test/java
All test java source files
src/main/resource
All properties files. For example, application.properties
...
pom.xml
POM.XML File Contents:
<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>Database</groupId>
<artifactId>Executor</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>DatabaseExecutor</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.framework.version>5.2.0.RELEASE</spring.framework.version>
<spring.framework.group.id>org.springframework</spring.framework.group.id>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<fully.qualified.main.class>com.applications.App</fully.qualified.main.class>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>12.2.0.1</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.2.0</version>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>${fully.qualified.main.class}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have created a build.bat file to build the code having the below content.
#ECHO OFF
call mvn -e pre-clean
call mvn -e clean
call mvn -e compile
call mvn -e package -DskipTests
Command Prompt Logs:
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< Database:Executor >--------------------------
[INFO] Building DatabaseExecutor 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.146 s
[INFO] Finished at: 2021-02-02T19:10:26+05:30
[INFO] ------------------------------------------------------------------------
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< Database:Executor >--------------------------
[INFO] Building DatabaseExecutor 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # Executor ---
[INFO] Deleting C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.465 s
[INFO] Finished at: 2021-02-02T19:10:28+05:30
[INFO] ------------------------------------------------------------------------
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< Database:Executor >--------------------------
[INFO] Building DatabaseExecutor 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Executor ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Executor ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.165 s
[INFO] Finished at: 2021-02-02T19:10:33+05:30
[INFO] ------------------------------------------------------------------------
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< Database:Executor >--------------------------
[INFO] Building DatabaseExecutor 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Executor ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Executor ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Executor ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # Executor ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Executor ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:copy-dependencies (copy-dependencies) # Executor ---
[INFO] Copying log4j-api-2.14.0.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\log4j-api-2.14.0.jar
[INFO] Copying log4j-core-2.14.0.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\log4j-core-2.14.0.jar
[INFO] Copying junit-3.8.1.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\junit-3.8.1.jar
[INFO] Copying spring-core-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-core-5.2.0.RELEASE.jar
[INFO] Copying spring-jcl-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-jcl-5.2.0.RELEASE.jar
[INFO] Copying spring-context-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-context-5.2.0.RELEASE.jar
[INFO] Copying spring-aop-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-aop-5.2.0.RELEASE.jar
[INFO] Copying spring-beans-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-beans-5.2.0.RELEASE.jar
[INFO] Copying spring-expression-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-expression-5.2.0.RELEASE.jar
[INFO] Copying ojdbc14-12.2.0.1.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\ojdbc14-12.2.0.1.jar
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) # Executor ---
[INFO] Building jar: C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\Executor-0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.292 s
[INFO] Finished at: 2021-02-02T19:10:39+05:30
[INFO] ------------------------------------------------------------------------
Though the executable jar file is getting created successfully but the properties file is missing in the jar file. I'm not sure what is the mistake here. Can somebody please point out the mistake or tell me if I missed something.
Thanks In Advance,
Varun Jain
I resolved it myself by creating the new project and copying the contents from this project to the newly created project.
Basically I have a Maven Project and I am trying to generate a jar of my project using mvn clean compile package through spring tool suite using below pom.xml.
After the command is executed, I get 2 jar files generated in my target folder - {project-name}.jar & {project-name}.jar.original
The .jar file contains
Spring boot framework class files having this contents while the .jar.original file contains actual class files of my application.
Snapshot of target folder
I also tried using mvn clean install but no luck with it. Moreover, the only 1 file is installed which is useless for me, because it does not contain any class files of my application but contains spring framework classes.
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.commonporject</groupId>
<artifactId>commonporject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>commonporject</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc4</artifactId>
<version>10.1</version>
</dependency>
<!-- other dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Console:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.commonporject:commonporject >----------------------
[INFO] Building commonporject 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # commonporject ---
[INFO] Deleting C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # commonporject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # commonporject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # commonporject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # commonporject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # commonporject ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # commonporject ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) # commonporject ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) # commonporject ---
[INFO] Building jar: C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\commonporject-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.0.RELEASE:repackage (repackage) # commonporject ---
[INFO] Replacing main artifact C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\commonporject-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.706 s
[INFO] Finished at: 2018-11-04T12:28:37+05:30
[INFO] ------------------------------------------------------------------------
spring-boot-maven plugin by default uses the repackage goal which packages all dependencies mentioned in the pom file. When this happens, your project's classes and resources jar is renamed to "original".
Please refer the below documentation for more details about this plugin.
https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html
How are the dependencies for JSON Processing, JSR 374, handled from gradle? Working examples would be greatly appreciated.
context: below is what I have with maven; looking to migrate this to gradle.
build is ok, even if there are duplicates:
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
thufir#dur:~/NetBeansProjects/HelloJsonMaven$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloJsonMaven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # HelloJsonMaven ---
[INFO] Deleting /home/thufir/NetBeansProjects/HelloJsonMaven/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # HelloJsonMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # HelloJsonMaven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /home/thufir/NetBeansProjects/HelloJsonMaven/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # HelloJsonMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/thufir/NetBeansProjects/HelloJsonMaven/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # HelloJsonMaven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # HelloJsonMaven ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # HelloJsonMaven ---
[INFO] Building jar: /home/thufir/NetBeansProjects/HelloJsonMaven/target/HelloJsonMaven-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-shade-plugin:3.1.0:shade (default) # HelloJsonMaven ---
[INFO] Including javax.json:javax.json-api:jar:1.1 in the shaded jar.
[INFO] Including org.glassfish:javax.json:jar:1.0.4 in the shaded jar.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] javax.json-1.0.4.jar, javax.json-api-1.1.jar define 25 overlapping classes:
[WARNING] - javax.json.stream.JsonParser
[WARNING] - javax.json.stream.JsonParserFactory
[WARNING] - javax.json.JsonString
[WARNING] - javax.json.JsonValue
[WARNING] - javax.json.stream.JsonLocation
[WARNING] - javax.json.Json
[WARNING] - javax.json.stream.JsonParsingException
[WARNING] - javax.json.stream.JsonParser$Event
[WARNING] - javax.json.JsonWriter
[WARNING] - javax.json.JsonValue$ValueType
[WARNING] - 15 more...
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /home/thufir/NetBeansProjects/HelloJsonMaven/target/HelloJsonMaven-1.0-SNAPSHOT.jar with /home/thufir/NetBeansProjects/HelloJsonMaven/target/HelloJsonMaven-1.0-SNAPSHOT-shaded.jar
[INFO] Dependency-reduced POM written at: /home/thufir/NetBeansProjects/HelloJsonMaven/dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.616 s
[INFO] Finished at: 2017-10-21T12:15:07-07:00
[INFO] Final Memory: 18M/61M
[INFO] ------------------------------------------------------------------------
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
and the JAR actually runs:
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
thufir#dur:~/NetBeansProjects/HelloJsonMaven$ java -jar target/HelloJsonMaven-1.0-SNAPSHOT.jar
Oct 21, 2017 12:15:19 PM net.bounceme.dur.hello_json_maven.Main props
INFO: {foo=bar}
Oct 21, 2017 12:15:20 PM net.bounceme.dur.hello_json_maven.JsonOperations createJsonObject
INFO: creating..
Oct 21, 2017 12:15:20 PM net.bounceme.dur.hello_json_maven.Main json
INFO: {"name":"Falco","age":3,"biteable":false}
thufir#dur:~/NetBeansProjects/HelloJsonMaven$
sample code:
package net.bounceme.dur.hello_json_maven;
import java.math.BigDecimal;
import java.util.logging.Logger;
import javax.json.Json;
import javax.json.JsonObject;
public class JsonOperations {
private static final Logger log = Logger.getLogger(JsonOperations.class.getName());
public void loadJsonFromFile(String jsonFileName) {
log.info(jsonFileName);
}
public JsonObject createJsonObject() {
// Create Json and serialize
log.info("creating..");
JsonObject json = Json.createObjectBuilder()
.add("name", "Falco")
.add("age", BigDecimal.valueOf(3))
.add("biteable", Boolean.FALSE).build();
String result = json.toString();
log.fine(json.toString());
return json;
}
}
Having been down this road before, seems prudent to ask before going too far down any false paths.
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>net.bounceme.dur</groupId>
<artifactId>HelloJsonMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<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-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>net.bounceme.dur.hello_json_maven.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax.json/javax.json-api -->
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
</project>
everyone. I'm trying to sign an Android APK with Maven Jarsigner. I followed the instructions on the maven-jarsigner site and told it to use my own keystore and verify. It doesn't look like the jarsigner plugin is even running from my pom.xml, much less verifying. I'm using Codenvy as my environment right now, so Maven console commands are unavailable to me. Any help would be appreciated. Here's my 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.kealinghornets.mapsapplication</groupId>
<artifactId>mobile-android-java-basic</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>MapsApp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>4.1.1.4</platform.version>
<android.plugin.version>3.8.0</android.plugin.version>
<android.sdk.platform.version>20</android.sdk.platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.jdroidframework</groupId>
<artifactId>google-play-services</artifactId>
<type>apklib</type>
<version>LATEST</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>java</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<defaultGoal>install</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign</id>
<goals>
<goal>sign</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>${project.basedir}/mapsapp.keystore</keystore>
<storepass>maps_app</storepass>
<keypass>maps_app</keypass>
<alias>maps_app</alias>
<verbose>true</verbose>
<certs>true</certs>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<sign>
<debug>false</debug>
</sign>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>${android.sdk.platform.version}</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
Here's my Maven output from the build:
[INFO] Injecting source code into builder...
[INFO] Source code injection finished
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MapsApp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # mobile-android-java-basic ---
[INFO]
[INFO] --- android-maven-plugin:3.8.0:generate-sources (default-generate-sources) # mobile-android-java-basic ---
[DEBUG] Expanding: /home/codenvy/.m2/repository/com/jdroidframework/google-play-services/0.6.0/google-play-services-0.6.0.apklib into /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, -m, -J, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/r, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar]
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, --non-constant-id, -m, -J, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/r, --custom-package, com.google.android.gms, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar]
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) # mobile-android-java-basic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/src/main/resources
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/generated-sources/extracted-dependencies/src/main/resources
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/src
[INFO]
[INFO] --- android-maven-plugin:3.8.0:consume-aar (default-consume-aar) # mobile-android-java-basic ---
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # mobile-android-java-basic ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes
[INFO]
[INFO] --- android-maven-plugin:3.8.0:proguard (default-proguard) # mobile-android-java-basic ---
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) # mobile-android-java-basic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # mobile-android-java-basic ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # mobile-android-java-basic ---
[INFO] No tests to run.
[INFO]
[INFO] --- android-maven-plugin:3.8.0:emma (default-emma) # mobile-android-java-basic ---
[INFO]
[INFO] --- android-maven-plugin:3.8.0:dex (default-dex) # mobile-android-java-basic ---
[INFO] /usr/local/jdk1.7.0_71/jre/bin/java [-Xmx1024M, -jar, /usr/local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar, --dex, --output=/media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes.dex, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/classes, /home/codenvy/.m2/repository/com/jdroidframework/google-play-services/0.6.0/google-play-services-0.6.0.apklib, /home/codenvy/.m2/repository/android/google-play-services/r21/google-play-services-r21.jar, /home/codenvy/.m2/repository/com/google/android/support-v4/r7/support-v4-r7.jar]
[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) # mobile-android-java-basic ---
[INFO] Building jar: /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.jar
[INFO]
[INFO] --- android-maven-plugin:3.8.0:apk (default-apk) # mobile-android-java-basic ---
[INFO] Enabling debug build for apk.
[INFO] /usr/local/android-sdk-linux/build-tools/21.1.1/aapt [package, -f, -M, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/AndroidManifest.xml, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/res, -S, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/unpack/apklibs/com.jdroidframework_google-play-services_apklib_0.6.0/res, --auto-add-overlay, -I, /usr/local/android-sdk-linux/platforms/android-20/android.jar, -F, /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.ap_, --debug-mode]
[INFO]
[INFO] --- android-maven-plugin:3.8.0:internal-pre-integration-test (default-internal-pre-integration-test) # mobile-android-java-basic ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO]
[INFO] --- android-maven-plugin:3.8.0:internal-integration-test (default-internal-integration-test) # mobile-android-java-basic ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # mobile-android-java-basic ---
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.apk to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.apk
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/pom.xml to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.pom
[INFO] Installing /media/ephemeral1/builder/maven/builds/build-4794906119007517519/androidmaps/target/mobile-android-java-basic.jar to /home/codenvy/.m2/repository/org/kealinghornets/mapsapplication/mobile-android-java-basic/1.0-SNAPSHOT/mobile-android-java-basic-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.161s
[INFO] Finished at: Thu Feb 26 19:57:09 UTC 2015
[INFO] Final Memory: 22M/398M
[INFO] ------------------------------------------------------------------------
[INFO] Project androidmaps successfully build
The maven-jarsigner-plugin is declared inside pluginManagement section, so it will not be executed. pluginManagement is only supposed to be used to factor configuration on a plugin for different Maven modules.
Note that the android-maven-plugin is in fact executed because it it also declared inside the plugins section, so it inherits from the declaration made in pluginManagement.
You should move the maven-jarsigner-plugin code into the plugins section.