Why plugin protobuf does not generate classes in the target folder? - java

I just started to study jrpc.I created a simple proto file in the proto package.
syntax = "proto3";
service HelloWorldService {
rpc hello(HelloRequest) returns (HelloResponse) {}
}
message HelloRequest {
string text = 1;
}
message HelloResponse {
string text = 1;
}
I use maven.In the pom.xml file I have dependencies like this
<?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>org.example</groupId>
<artifactId>grpc-hello-server</artifactId>
<version>1.0-SNAPSHOT</version>
<name>GRPC</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.48.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.48.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.48.0</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.9.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.24.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Then i click reload all maven projects button and then in maven lifecycle i click package run. And if i understand correctly my protobuf plugin must created classes in target/generated-sources folder. But it's empty. I don't understand why, i cleaned maven, installed and then again used package command.And that didn't help.Please tell me why my files are not being created?

Proto files should be stored at src/main/proto

Related

Maven: resolve versions with flatten without expanding the dependencies

I want to resolve all the revision tags after the build, so I'm using flatten. I have a multi module project like this:
A (root)
|_B (parent = A, dependencyManagement with version = ${revision}
|_C (parent = B, dependencies declared in dependencyManagement without specifying the version)
The problem is that in the flattened pom of B the ${revision} is not resolved. Moreover, in the flattened pom of C the version is still missing, whereas I'd expect to find the version declared in the dependencyManagement in B.
This is how I configured flatten:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I tried to add this section inside <configuration>:
<pomElements>
<dependencyManagement>expand</dependencyManagement>
<dependencies>expand</dependencies>
</pomElements>
This partially solves the problem, because it resolves all the version, but the pom become way too verbose, because it expands all the dependencies of the parent. So the result is that the flattened pom of C explicitly contains all the dependencies declared in B e A, and the dependencyManagement of B.
Is there a way to just solve the versions without expanding all the dependencies in the child pom?
I solved this issue adding <flattenMode>bom</flattenMode> to <configuration> section in my module containing only dependencyManagement section.
According to Maven Flatten Plugin Documentation
Option bom is Like ossrh but additionally keeps dependencyManagement
and properties. Especially it will keep the dependencyManagement as-is
without resolving parent influences and import-scoped dependencies.
This is useful if your POM represents a BOM (Bill Of Material) and you
do not want to deploy it as is (to remove parent and resolve version
variables, etc.).
You can see an example below
Root module
<?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.github.eljaiek.autopilot</groupId>
<artifactId>autopilot</artifactId>
<packaging>pom</packaging>
<version>${revision}</version>
<properties>
<revision>1.0.0.M1</revision>
<flatten.mode>clean</flatten.mode>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules>
<module>autopilot-testng-runner</module>
<module>autopilot-dependencies</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>${flatten.mode}</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
autopilot-dependencies module
<?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>
<parent>
<artifactId>autopilot</artifactId>
<groupId>com.github.eljaiek.autopilot</groupId>
<version>${revision}</version>
</parent>
<artifactId>autopilot-dependencies</artifactId>
<packaging>pom</packaging>
<properties>
<slf4j.version>1.7.26</slf4j.version>
<flatten.mode>bom</flatten.mode>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>autopilot-testng-runner</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
<!--testng-->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0</version>
</dependency>
<!--dependency injection-->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>com.netflix.governator</groupId>
<artifactId>governator</artifactId>
<version>1.17.9</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.25.0-GA</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
autopilot-testng-runner module
<?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>
<parent>
<groupId>com.github.eljaiek.autopilot</groupId>
<artifactId>autopilot</artifactId>
<version>${revision}</version>
</parent>
<artifactId>autopilot-testng-runner</artifactId>
<properties>
<flatten.mode>oss</flatten.mode>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.governator</groupId>
<artifactId>governator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>autopilot-dependencies</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
autopilot-testng-runner pom flattened
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.eljaiek.autopilot</groupId>
<artifactId>autopilot-testng-runner</artifactId>
<version>1.0.0.M1</version>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.netflix.governator</groupId>
<artifactId>governator</artifactId>
<version>1.17.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Maven plugin external dependencies are not resolved

I am writing a maven plugin using Mojo classes. The plugin requires a dependency called jcifs and included it in the pom.xml of the plugin. I am able build the plugin and it is deployed into my local repository. I can find the jar file and pom.xml in my local repository.
When I use this plugin in another project in my local system, when executing the plugin goal, I am getting an exception saying the class not found. But the class is coming from the jcifs jar and it is included as part of the dependency for my plugin.
I am not able to figure out what I am missing here. Any help is appreciated
Following is the plugin 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.mayuran19.maven.plugin</groupId>
<artifactId>LocalToRemoteRepo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>localtoremoterepo-maven-plugin</name>
<properties>
<mavenVersion>3.2.1</mavenVersion>
<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>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Following show is the pom.xml of the project that use this plugin
<?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.mayuran19.maven.plugin</groupId>
<artifactId>LocalToRemoteRepo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>localtoremoterepo-maven-plugin Test</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>4.3.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.mayuran19.maven.plugin</groupId>
<artifactId>LocalToRemoteRepo</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<localRepoDir>C:/Users/smayuran.SITBCS/.m2/repository</localRepoDir>
<remoteRepoDir>smb://192.168.9.196/internal</remoteRepoDir>
<username>G3App</username>
<password>P#ssword$1</password>
</configuration>
</plugin>
</plugins>
</build>
Error I am getting is class not found exception from the library jcifs
You can do this way, if you want:
**Step 1:**Download the jar file to you local machine
**Step 2:**Moving you jar to you maven repo:Run as shown bellow
Example:
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
<version>3.10.1</version>
</dependency>
mvn install:install-file -Dfile=C:\Users\username\Desktop\mockserver-netty-3.10.1.jar -DgroupId=org.mock-server -DartifactId=mockserver-netty -Dversion=3.10.1 -Dpackaging=jar

Maven dependencies not coming in eclipse for multi module maven project

I have a multi module maven project. Please find below the parent 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.rohit.patterns</groupId>
<artifactId>design-patterns</artifactId>
<version>1.0.1</version>
<packaging>pom</packaging>
<name>React.js Blank Project (from https://github.com/making/maven-reactjs-blank)</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.7.21</slf4j.version>
<logback.version>1.1.7</logback.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>gulp</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo message="Gulp!" />
<exec executable="gulp">
<arg value="build" />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/META-INF/resources</outputDirectory>
<resources>
<resource>
<directory>dest</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modules>
<module>cache</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
The child POM is as follows.
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.rohit.patterns</groupId>
<artifactId>design-patterns</artifactId>
<version>1.0.1</version>
</parent>
<groupId>com.rohit.patterns</groupId>
<artifactId>cache</artifactId>
<version>1.0.1</version>
<name>cache</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I have declared Logging from slf4j in parent but no maven dependencies for the same is generated in eclipse hence I am unable to use logging in the code. Can anyone let me know what is wrong here.
Using <dependencyManagement> in a parent pom allows to set the usable dependencies by the child modules.
It is a good thing as it centralizes them and specifies one and only one version.
But to use them, child modules have to declare them in the <dependencies> tag of the <build> tag.
You could for example modify the child pom in this way :
<dependencies>
...
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
...
</dependencies>
If you consider that these dependencies should be added in any child modules, favor dependencies over dependencyManagement in the parent pom declaration :
<dependencies>
...
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
...
</dependencies>
Now, you don't need to declare any of these in the child modules as these dependencies will be already included.

Driver class not found

I`m getting an error in my Maven mysql project in netbeans when I try and clean build. The error is:
Failed to execute goal org.codehaus.mojo:sql-maven-plugin:1.5:execute (default) on project utopiaDatabase: Driver class not found: com.mysql.jdbc.Driver
I looked around and figured this is probably because my project isn`t finding my mysql-connector-java, but I have it added as a dependency and everything in my POM file looks fine, do you know why it might not be finding it?
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.eeu46f</groupId>
<artifactId>utopiaDatabase</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<profiles>
<profile>
<id>hsql</id>
<dependencies>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
<classifier>jdk6debug</classifier>
</dependency>
</dependencies>
<properties>
<jdbc.url>jdbc:hsqldb:mem:testDB</jdbc.url>
<jdbc.username>SA</jdbc.username>
<jdbc.password></jdbc.password>
<jdbc.driver>org.hsqldb.jdbc.JDBCDriver</jdbc.driver>
</properties>
</profile>
<profile>
<id>mysql</id>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<jdbc.url>jdbc:mysql:taken out for security</jdbc.url>
<jdbc.username>taken out for security</jdbc.username>
<jdbc.password>taken out for security</jdbc.password>
<jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
<classifier>jdk6debug</classifier>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<driver>${jdbc.driver}</driver>
<url>${jdbc.url}</url>
<username>${jdbc.username}</username>
<password>${jdbc.password}</password>
</configuration>
<executions>
<execution>
<phase>generate-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<srcFiles>
<srcFile>src/test/resources/1-destroy.sql</srcFile>
<srcFile>src/test/resources/2-create.sql</srcFile>
<srcFile>src/test/resources/3-insert.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<name>utopiaDatabase</name>
database properties file in src/main/resources:
jdbc.url=${jdbc.url}
jdbc.username=${jdbc.username}
jdbc.password=${jdbc.password}
jdbc.driver=${jdbc.driver}
I have tried adding mysql-connector-java-5.1.6 as a dependency in my maven project manually also. Thanks in advance
If you look at the homepage of the sql-maven-plugin under "Usage" it clearly shows that you have to give your driver as a dependency to the sql-maven-plugin. You only gave it as a dependency of your project.
If your project needs that dependency as well or not is a different story.

no main manifest attribute error for maven project

i have a project in eclipse where i try to run a selenium junit test.
I converted the project to Maven
When i run this java -jar My-Test-0.0.1-SNAPSHOT.jar
It says:
no main manifest attribute, in My-Test-0.0.1-SNAPSHOT.jar
What is wrong with me pom file?
The pom.xml file:
<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.blogspot.test</groupId>
<artifactId>My-Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>My-Test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
</dependency>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>all</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</dependencies>
</project>
Is your project a web project?? Because as I know, Selenium only works with web projects. And there you have your project packaged as a jar (not as a war)

Categories

Resources