How to package dependencies with maven nbm plugin - maven

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>

Related

Declaring of maven dependency check as plugin vs dependency

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>

OSGi bundle compile error

When I build my bundle, maven throws the exception:
[ERROR] Bundle com.onboard:com.onboard.service.security:bundle:3.0.0-SNAPSHOT : Exporting packages that are not on the Bundle-Classpath[Jar:dot]: [about_files, XXX]
[ERROR] Error(s) found in bundle configuration
I use maven-bundle-pluginto build my code:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<manifestLocation>src/main/resources/META-INF</manifestLocation>
<instructions>
<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>${bundle.Export-Package};version="${project.version}"</Export-Package>
<Private-Package>!${bundle.Export-Package};${bundle.Export-Package}.internal.*</Private-Package>
<_include>osgi.bnd</_include>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
And my dependencies are:
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>org.springframework.security.web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web.servlet</artifactId>
</dependency>
<dependency>
<groupId>org.elevenframework</groupId>
<artifactId>org.elevenframework.web.api</artifactId>
</dependency>
<dependency>
<groupId>com.onboard</groupId>
<artifactId>com.onboard.domain.model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.onboard</groupId>
<artifactId>com.onboard.service.common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.onboard</groupId>
<artifactId>com.onboard.service.web</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.onboard</groupId>
<artifactId>com.onboard.service.account</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.onboard</groupId>
<artifactId>com.onboard.service.collaboration</artifactId>
<version>${project.version}</version>
</dependency>
The application running good a few days ago. I think it is the modify of dependency com.onboard.XXX lead to this. But I do not what it is. What shall I do?
This appears to be the same question that you asked here with much more information
Your maven-bundle-plugin configuration is exporting the packages from the maven property bundle.Export-Package
<Export-Package>${bundle.Export-Package};version="${project.version}"</Export-Package>
A bundle should never export a package that it does not contain. In this case your bundle is trying to export about_files and XXX. Both of these things look very wrong.
You haven't included the full POM, nor have you included the osgi.bnd file referenced in your maven-bundle-plugin configuration, but it looks as though this misconfiguration is the source of the error.
In my view trying to automate package exports and private packages with properties is usually a mistake. In a maven module you almost invariably want to private package all of the classes from the src/main/java folder, include the files from src/main/resources and export specific named packages. Incidentally this is how the bnd-maven-plugin works.

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 deploy in a gwt-maven project

first of all, I'm not sure which folders and files i have to deploy in a gwt-maven project
I've got:
.gwt
.settings
bin
src/main/java
target
war
pom.xml
I'm pretty sure, I've to deploy the pom.xml somehow and the target folder. But my target folder doesn't contain a pom.xml which I need for deploying on a jetty server
Second:
I've installed maven on my webserver, but apart from embedding the jetty-maven-plugin in the pom.xml (by
org.eclipse.jetty
jetty-maven-plugin
)
I have absolutely no clue how to get this project running on a jetty server.
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
SiedlerVonCatanC
SiedlerVonCatanC
war
src/main/java
src/main/java
*/.java
maven-compiler-plugin
3.1
1.7
1.7
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<module>main.java.de.swp.catan.SiedlerVonCatanC</module>
<runTarget>SiedlerVonCatanC.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.5.1</version>
</dependency>
<!-- SmartGWT -->
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>3.0</version>
</dependency>
<!-- Event Service -->
<dependency>
<groupId>de.novanic.gwteventservice</groupId>
<artifactId>gwteventservice</artifactId>
<version>1.2.0</version>
</dependency>
<!-- Java-Mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<!-- Apache Commons -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
<!-- htmlunit (wird im Projekt irgendwo genutzt) -->
<!-- <dependency> <groupId>net.sourceforge.htmlunit</groupId> <artifactId>htmlunit</artifactId>
<version>2.4</version> </dependency> -->
<!-- Guice -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<!-- Connector for JDBC -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>com.smartgwt</id>
<url>http://www.smartclient.com/maven2</url>
</repository>
</repositories>
<version>0.2</version>
have the maven-jetty-plugin included in your pom , under plugins and then you can run it as
mvn jetty:run
thanks
If you want to use maven plugin to run embedded jetty for development then easy way using command-line (which I recommend for start) is:
Edit: Please note this is not related to the existing project.Its process from scratch. Just run these command from a new directory where you would like a new gwt project to be created.
Dowload gwt maven plugin http://mojo.codehaus.org/gwt-maven-plugin/. In command line list you can see it as org.codehaus.mojo:gwt-maven-plugin (Maven plugin for the Google Web Toolkit.) I see that you have this plugin in POM, but if you are at loss here the simple steps from command-line to achive this are:
mvn archetype:generate
enter org.codehaus.mojo:gwt-maven-plugin in search prompt
comfirm the resutl with enter
set-up the maven project configuration as prompted
run the project with mvn gwt:run from the folder where you have pom.xml
These two steps will run a sample project for you which you can further modify and experiment while learning how it works.,
As for directories:
The maven compiles all your stuff in target directory and that is used for deployment or running embedded jetty.

maven ignoring findbugs suppressFBWarnings annotation

I have 2 projects that I am using the FindBugs plugin in maven to identify bugs. I am also using the #SuppressFBWarnings annotation to ignore specific bugs.
With the first project, I added the dependancies to the pom.xml and both the findbugs report and the annotation worked fine. With the second project, the report gets generated, but it still identifies bugs that I have suppressed using the annotation.
I run mvn clean install site to generate the reports on my machine in the build folder.
Each of the 2 projects I mentioned, have sub-projects with their own pom.xml files in their sub-directories, so in the parent directory, I also have a pom.xml. This directory layout is mirrored identically in both of the main projects.
Here is the XML I added to the parent poms under the <reporting> tag:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<fork>true</fork>
<threshold>Low</threshold>
<effort>Min</effort>
</configuration>
</plugin>
Also, in this same parent pom, I added this to the <dependencyManagement><dependencies> section:
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>2.0.1</version>
</dependency>
This is identical in both of the main projects poms.
Now, in the sub-projects where I actually use the #SuppressFBWarnings annotation, and only in that particular sub-project, I have this under <dependencies>:
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>2.0.1</version>
</dependency>
Also, this is mirrored in the other working project. I copied and pasted directly.
One project works perfect and I can successfully suppress false positives. The other project completely ignores the #SuppressFBWarnings anotation, and I can't seem to fix it.
Is there something I'm missing here?
I think that if an annotation is not found, instead of giving an error, it will just ignore it? How can I tell if its not found?
Hopefully this is a simple fix.
Thanks.
#SuppressFBWarnings was introduced with the annotation in version 3. That's why it should look like this:
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1</version>
</dependency>
Try to add annotations artifcat to the plugin dependencies :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<fork>true</fork>
<threshold>Low</threshold>
<effort>Min</effort>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
</plugin>
Ensure that the dependency added is in between the dependencies tags.
Like this:
<dependencies>
<dependency>
<groupId>something</groupId>
<artifactId>something</artifactId>
<version>something</version>
</dependency>
<dependencies>

Resources