Declaring of maven dependency check as plugin vs dependency - spring-boot

what is the difference between declaring the maven dependency check plugin as:
<dependency>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>${dependency-check-maven.version}</version>
<type>maven-plugin</type>
</dependency>
and
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>${dependency-check-maven.version}</version>
</plugin>

Related

How to copy dependencies which are also in type - pom into a location using maven dependency plugin

following dependencies need to be resolved and copy child dependencies into a specific location.
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>${version.org.wildfly.wildfly-ejb-client-bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-jms-client-bom</artifactId>
<version>${version.org.wildfly.wildfly-jms-client-bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
But when i copy using maven dependency plugin, only the pom files get copied, not the dependencies defined in those poms.
my plugin is as below,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>${version.org.wildfly.wildfly-ejb-client-bom}</version>
<type>pom</type>
<outputDirectory>${project.build.directory}/Lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-jms-client-bom</artifactId>
<version>${version.org.wildfly.wildfly-jms-client-bom}</version>
<type>pom</type>
<outputDirectory>${project.build.directory}/Lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
any clues?
Using <scope>import</scope> manage dependencies from other projects. See this on Maven documentation for detail solution.
I had the same problem and struggled for a whole day. The scope <scope>import</scope> does only work with dependencyManagement section, we don't really want here. The answer is simple, let the Maven dependency:copy-dependencies plugin get you all transitive dependencies for you - except the pom files.
As the docs state set <excludeTransitive>false</excludeTransitive> and <excludeTypes>pom</excludeTypes>, that should do the trick.
There's also a way to do this without the plugin configuration in your pom, but on the commandline:
mvn --batch-mode --no-transfer-progress -f /path/to/your/pom.xml dependency:copy-dependencies -DexcludeTypes=pom -DoutputDirectory=/Lib
Here's a GitHub gist with a full example. As the default in Maven for excludeTransitives is false, you're example should have worked, but also included the pom files.

Set up a testing classes dependency upon another module in a maven project

A maven project has a core module and a sql module. The sql module's test classes should extend some of the core module test classes. What needs to be done in the sql module pom.xml to set up that dependency?
Figured it out: the way is to add a test-jar with "test" scope.
<type>test-jar</type>
<scope>test</scope>
So here is the full dependency for my case
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
You will have to create a test jar out of your core module, and then add it as a test scoped dependency in your sql module.
Add the below plugin declaration to the build/plugins section of your core module's pom file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
Now add this test jar as a dependency in your sql module
<dependency>
<groupId>com.coderplus.test</groupId>
<artifactId>coremodule</artifactId>
<version>1.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

How to exclude a dependency defined in the pom.xml from a plugin defined in the same pom

I have a pom.xml in which I have a dependency defined as:
<dependency>
<groupId>abc.xyz.pig</groupId>
<artifactId>pig</artifactId>
<version>10</version>
<scope>provided</scope>
</dependency>
I want to define a new plugin in the same file, for which I need a higher version of the same dependency. How do I make my plugin use a higher version of the dependency and ignore the lower version defined above?
I tried adding the dependency of the newer version in my plugin definition like this, but it didn't work:
<plugin>
<groupId>my_plugin</groupId>
<artifactId>my_plugin_artifact</artifactId>
<version>0.1.1</version>
<executions>
<execution>
<goals>
<goal>my_plugin_goal</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>abc.xyz.pig</groupId>
<artifactId>pig</artifactId>
<version>11</version>
</dependency>
</dependencies>
</plugin>

How to package dependencies with maven nbm plugin

I have modified netbeans module jar that I want to package with my module. How do I do this ?
Dependency in context
<dependency>
<groupId>org.netbeans.modules</groupId>
<artifactId>org-netbeans-modules-db-dataview</artifactId>
<version>${netbeans.platform.version}</version>
<scope>system</scope>
<systemPath>${dbdataview}</systemPath>
</dependency>
mvn nbm configuration
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<version>3.5</version>
<extensions>true</extensions>
<configuration>
<additionalArguments>${netbeans.run.params.ide}</additionalArguments>
<netbeansInstallation>/home/venkat/netbeans-7.1.1/</netbeansInstallation>
<keystore>keystore</keystore>
<keystorealias>ezondaice</keystorealias>
<keystorepassword>ezondaice</keystorepassword>
</configuration>
</plugin>
Edit
I have the following dependency as well. This one seems to get packaged with the nbm inside
/netbeans/modules/ext/org.yaml/. Not sure why the other dependency is not being packaged into nbm.
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.11-SNAPSHOT</version>
</dependency>

Can't get QueryDsl / APT to generate Q classes

I'm trying to use QueryDsl in a new Spring project. I'm new to QueryDsl, and pretty new to maven and Spring, so I may be missing something fairly basic, but I can't get QueryDsl / maven-apt-plugin to generate my Q classes. The Querydsl reference makes sound so easy; I think I did exactly what it said:
I configured pom.xml with:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
and:
<repository>
<id>QUERYDSL</id>
<url>http://source.mysema.com/maven2/releases</url>
<layout>default</layout>
</repository>
and:
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>2.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
I have two #Entity's in that project.
mvn clean install does not result in any output to target/generated-sources/java/
What am I missing?
I tried mvn apt:process, and it results in:
[ERROR] Failed to execute goal com.mysema.maven:maven-apt-plugin:1.0.3:process (default-cli) on project logging-implementation: Either processor or processors need to be given -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.mysema.maven:maven-apt-plugin:1.0.3:process (default-cli) on project logging-implementation: Either processor or processors need to be given
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
Any suggestions?
Thanks!
OK, I got it.
I don't understand it (I'm a Maven noob), but here's what worked:
In the parent pom.xml, I have
<build>
<pluginManagement>
<plugins>
the maven-apt-plugin definition shown above
</plugin>
<pluginManagement>
</build>
and in the project's POM I have:
<build>
<plugins>
the **exact same** maven-apt-plugin definition shown above
</plugin>
</build>
without the <pluginManagement> level betweeen <build> and <plugins>, following the instructions at http://mojo.codehaus.org/apt-maven-plugin/plugin-info.html
You are calling the goal directly, but the configuration is execution specific. So either use apt via the standard maven lifecycle or make the configuration general.

Resources