How to download and compile SwingX - java

This must be mostly a newbie Maven question.
Since SwingX migrated to Kenai, there are warnings all over the website that many links are broken.. so here is my best attempt.
I went to https://java.net/projects/swingx/downloads/directory/releases
Clicked on "SwingX 1.6.4 All - Sources" (really a non-intuitive, hit-or-miss choice for me, but perhaps it's a naming convention other people understand?)
This downloads swingx-all-1.6.4-sources.jar (why is it even a jar and not a zip?)
However, this source jar does not contain POM.XML.
So, I downloaded swingx-all-1.6.4.jar from the same link, renamed it to .zip, inflated. It does contain
META-INF\maven\org.swinglabs.swingx\swingx-all\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>
<parent>
<artifactId>swingx-project</artifactId>
<groupId>org.swinglabs.swingx</groupId>
<version>1.6.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>swingx-all</artifactId>
<packaging>jar</packaging>
<name>SwingX Complete</name>
<description>A Maven project to aggregate all modules into a single artifact.</description>
<properties>
<project.generatedDependencies>${project.generatedSourcesDirectoy}/dependencies</project.generatedDependencies>
</properties>
<!-- make the dependent swingx modules optional, since we're aggregating -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-graphics</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-core</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-mavensupport</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
<profiles>
<profile>
<id>jvnet-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>src-dependencies</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<classifier>sources</classifier>
<includeGroupIds>${project.groupId}</includeGroupIds>
<excludeArtifactIds>swingx-mavensupport</excludeArtifactIds>
<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
<outputDirectory>${project.generatedDependencies}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>add-dependencies-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.generatedDependencies}</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-dependencies-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.generatedDependencies}</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.generatedAnnotations}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
When I change to the above directory where POM.XML is located and do mvn install, it certainly builds a lot of stuff.. but also says:
[INFO] skip non existing resourceDirectory
F:\swingx\swingx-all-1.6.4\META-INF\m
Maven\org.swinglabs.swingx\swingx-all\src\main\resources
That's because the src directory is nonexistent. Which makes sense, because the .jar files in question is said to be binaries only, but I was hoping some Maven target would download sources or something... and if it's binary only, why does it need to be built? Confused.
At that point, I could probably either copy the src directory from the first zip file to the second, or copy the pom.xml from the second file to the first.. but I am having a feeling I am missing something, and there has to be a more straightforward way.
BTW, there is a third file at the same web page, swingx-mavensupport-1.6.4.jar
So I downloaded that, renamed it to .zip, inflated, found this file:
META-INF\maven\org.swinglabs.swingx\swingx-mavensupport\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>
<parent>
<artifactId>swingx-project</artifactId>
<groupId>org.swinglabs.swingx</groupId>
<version>1.6.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>swingx-mavensupport</artifactId>
<name>SwingX Maven Support</name>
</project>
Changed to its directory and ran mvn.install
However, that complained at the lack of a whole lot of files.
I must be getting it all wrong. What's the right way?

Use the following URL for SVN checkout: https://svn.java.net/svn/swingx~svn.
In trunk there is a correct pom.xml file (actualy many of them for different artifacts), so you can easily build the project yourself.
swingx-all-1.6.4-sources.jar (why is it even a jar and not a zip?)
That's the default way sources are packaged and distributed in Maven.

Related

Make windows stand-alone executable file for spring boot project and angular project which can access offline in windows

I have one jar file which bundles with UI now I want to make one standalone window executable file. in the jar file, I have code with PostgreSQL database tomcat server
my pom file for the project like
I want only one exe which has run directly on double click
<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">
<parent>
<groupId>dev.marco</groupId>
<artifactId>java-angular-example</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
</properties>
<artifactId>backend</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>frontend</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
....
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<mainClass>dev.marco.ShlowinApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
</project>
The closest I can think of would be launch4j, adding an exe launcher for your application. This will add the exe, but will not magically make it a desktop-application, for that you may need to adjust code.
A configuration in the pom.xml would look similar to the following:
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<outfile>target/${project.artifactId}.exe</outfile>
<jar>target/${project.artifactId}.jar</jar>
<dontWrapJar>false</dontWrapJar>
<addDependencies>true</addDependencies>
<errTitle>Error in launch4j plugin</errTitle>
<classPath>
<mainClass>${mainClass}</mainClass>
</classPath>
<icon>src/main/resources/Images/logo.ico</icon>
<jre>
<path>./java</path>
</jre>
<versionInfo>
<fileVersion>${project.version}.0</fileVersion>
<txtFileVersion>${project.version}.0</txtFileVersion>
<fileDescription>${description}</fileDescription>
<copyright>Copyright(c) ${distributor}</copyright>
<companyName>${distributor}</companyName>
<productVersion>${project.version}.0</productVersion>
<txtProductVersion>${project.version}.0</txtProductVersion>
<productName>${project.artifactId}</productName>
<internalName>${project.artifactId}</internalName>
<originalFilename>${project.artifactId}.exe</originalFilename>
<language>ENGLISH_UK</language>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>

Include source package and dependency only for a profile with Spring Boot maven plugin

In a Spring Boot based project of mine I want to create two different builds from the same project.
The decision on which build is generated should come from a maven profile.
I want to create one build (full) which includes a certain folder src/main/java/com/example/demo/full and a certain dependency, and a second build (default or light) build which does not include them.
Including the dependencies for build full works, but I don't know how to make sure the folder src/main/java/com/example/demo/full is only compiled for the full build.
Here 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<finalName>demo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>full</id>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
How can I manage to have the mentioned source-folder only compiled for profile full?
Add a second src folder like scr\foo and then add a profile in maven configure this src folder.
<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">
<build>
...
</build>
<profiles>
<profile>
<id>extraSource</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/foo/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Here the source folder is added using the Build Helper Plugin plugin for maven. As it is embedded in the build section of the specific profile, it is only active while executing maven with this profile (see the activation section)
there are problem with disabling one of your maven-source-plugin if this dependency is a part of parent which you cant not give ID to, ill recomend to use phase none with this code to one of your pom.xml files that will disable this.
I also recommend to use command: mvn -Prelease-profile help:effective-pom
to print if you have two of dependencies maven-source-plugin in your code, if yes, disable one of them with this code below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>none</phase>
</execution>
</executions>
</plugin>

How can I make scala-maven-plugin make see classes compiled by maven-compiler-plugin?

I can't use the scala-maven-plugin to build my Java-sources due to a bug in Scalac (https://issues.scala-lang.org/browse/SI-9853).
Splitting the build so that Java is compiled by the maven-compiler-plugin and Scala by the scala-maven-plugin was easy enough with the sources residing in src/main/java and src/main/scala.
Right now I am running into the problem that the Scala-classes can't see the Java-classes.
When doing mvn clean compile I get 'not found' for all Java-classes required by the Scala-classes. Checking 'target/classes' shows that the Java-classes are there.
I tried moving the Scala-build to different phases but the results remain the same.
How can I make the Scala-build see the classes already available in target/classes?
<?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>de.codepitbull.maven</groupId>
<artifactId>maven-scalac-bug</artifactId>
<version>3.4.0-SNAPSHOT</version>
<name>Scalac + Javac</name>
<properties>
<scala.version>2.11.8</scala.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<scope>provided</scope>
<version>${scala.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<sendJavaToScalac>false</sendJavaToScalac>
<args>
<arg>-target:jvm-1.8</arg>
<arg>-feature</arg>
<arg>-deprecation</arg>
<arg>-explaintypes</arg>
<arg>-unchecked</arg>
<arg>-Xlint</arg>
</args>
</configuration>
<executions>
<execution>
<id>java-compile-first</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The easiest workaround would be to split it into two submodules. That way you're able to reference the Java classes as dependency. After that generate an Uber jar or shaded jar with both modules inlined.

Install Jar Dependency to Local Repository as Part of Maven Build Process

I have a third-party jar that is a dependency of my project. Because of business constraints, I do not have access to an enterprise or company repository, which would definitely be my preference for this issue. But regardless, this third-party jar is not available publicly, and so it is included in the web project under src\main\resources.
This is a Maven project, and so I list this third-party jar as a compile time dependency, and include in my pom a build plugin that will install the third-party jar to my local repository as part of the build process; I tell Maven to perform this goal during the validate phase of the build lifecycle, which to my knowledge would be before any other Maven phase.
However, when I run a clean install and have my local repository cleared out, the build fails due to the third-party jar not being resolvable locally or in the Maven central repository. As far as I know, I have set up the pom correctly and I should be seeing Maven attempt to install the third-party jar locally before it begins dependency resolution.
The issue is that if the dependency is listed before the jar has ever been installed locally, the build will fail due to being unable to resolve that dependency. If I remove the third-party jar declaration and run the build, after dependency resolution occurs (which is the very first thing it does after the clean), but before any other phase, it will locally install the jar and things are fine. But to my knowledge, it should run the validate phase before it collects and resolves dependencies, and so the jar should be locally installed before it's resolved by Maven. Any ideas or thoughts?
My pom:
<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>com.company</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Web Services</name>
<description>This project will handle communication.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- This plugin installs the Evip jar from the project's resource folder to the local
repository for normal Maven consumption -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>install-evip-jar</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>install:install-file</argument>
<argument>-Dfile=${basedir}\src\main\resources\EVIPSoapServer.jar</argument>
<argument>-DgroupId=com.company</argument>
<argument>-DartifactId=EVIPSoapServer</argument>
<argument>-Dversion=1.0.0</argument>
<argument>-Dpackaging=jar</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<!-- EXCLUDE EVIPSOAPSERVER JAR FROM CLASSES DIRECTORY -->
<packagingExcludes>
${basedir}\src\main\resources\EVIPSoapServer.jar
</packagingExcludes>
<webResources>
<!-- INCLUDE SOURCE FILES WITH WAR -->
<resource>
<directory>${project.build.sourceDirectory}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<!-- mvn clean install tomcat:run-war to deploy Look for "Running war
on http://xxx" and "Setting the server's publish address to be /yyy" in console
output; WSDL browser address will be concatenation of the two: http://xxx/yyy?wsdl -->
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>start-tomcat</id>
<goals>
<goal>run-war</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<port>${test.server.port}</port>
<path>/webservice</path>
<fork>true</fork>
<useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
exec-maven-plugin
</artifactId>
<versionRange>
[1.2.1,)
</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!-- COMPILE DEPENDENCIES -->
<dependency>
<groupId>com.company</groupId>
<artifactId>EVIPSoapServer</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- PROVIDED/TEST DEPENDENCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The solution from http://randomizedsort.blogspot.com.es/2011/10/configuring-maven-to-use-local-library.html is based on having a file-based, project-scoped maven repository. Thus, the library is under your source code versioning. Install is one-time manual process, rather than a something specified in the pom.xml file
Three steps:
Create a folder in your project where you will keep the repo. Say lib.
Use Maven to install your jar to the lib directory.
mvn install:install-file -Dfile=path_to_mylib.jar ^
-DgroupId=com.mylib ^
-DartifactId=mylib ^
-Dversion=1.0 ^
-Dpackaging=jar ^
-DlocalRepositoryPath=path_to_my_project/lib
3.Update your pom.xml
<repositories>
<repository>
<!-- DO NOT set id to "local" because it is reserved by Maven -->
<id>lib</id>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.mylib</groupId>
<artifactId>mylib</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
Saw this question while looking for a solution to a similar problem. I know it's old, but wanted to share my solution. I ended up solving my problem by using the maven-install-plugin directly:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>whatevs</id>
<phase>validate</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${oracle.version}</version>
<packaging>jar</packaging>
<file>${basedir}/dev-setup/lib/ojdbc6.jar</file>
</configuration>
</execution>
</executions>
</plugin>
Works perfectly.
I suggest you modeling the external dependency as a separate project (think of it as a wrapper). Your current project may then be dependent on your own project that as part of its build can download the external JAR and package it into its own distributable.
Alrighty, arguing and preference aside, I did go with Sander's recommendation; it was the only one that really worked without custom Mojos, etc. I have a parent Maven project with a packaging of type pom and all it does is install the third-party jar (which could be any number of jars or dependencies) to my local repository. 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.company</groupId>
<artifactId>project-evip</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>EvipSoapServerJar</name>
<packaging>pom</packaging>
<modules>
<module>webservices</module>
</modules>
<build>
<plugins>
<!-- This plugin installs the Evip jar from the project's lib to the local
repository for normal Maven consumption -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>install-evip-jar</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>install:install-file</argument>
<argument>-Dfile=${basedir}\src\main\resources\EVIPSoapServer.jar</argument>
<argument>-DgroupId=com.company</argument>
<argument>-DartifactId=EVIPSoapServer</argument>
<argument>-Dversion=1.0.0</argument>
<argument>-Dpackaging=jar</argument>
</arguments>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
exec-maven-plugin
</artifactId>
<versionRange>
[1.2.1,)
</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Then, I created a Maven module under the parent Maven project and used the org.apache.cxf.archetype:cxf-jaxws-javafirst:2.7.7 archetype. I simply list the third-party jar as a compile-time dependency, and it's resolved and added to the resulting war. The child module's 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>project-evip</artifactId>
<groupId>com.company</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.company</groupId>
<artifactId>webservices</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Web Services</name>
<description>This project will handle communication.</description>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<!-- INCLUDE SOURCE FILES WITH WAR -->
<resource>
<directory>${project.build.sourceDirectory}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<!-- mvn clean install tomcat:run-war to deploy Look for "Running war
on http://xxx" and "Setting the server's publish address to be /yyy" in console
output; WSDL browser address will be concatenation of the two: http://xxx/yyy?wsdl -->
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>start-tomcat</id>
<goals>
<goal>run-war</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<port>${test.server.port}</port>
<path>/webservice</path>
<fork>true</fork>
<useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!-- COMPILE DEPENDENCIES -->
<dependency>
<groupId>com.company</groupId>
<artifactId>EVIPSoapServer</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- PROVIDED/TEST DEPENDENCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I appreciate all the help, thank you.
Corresponding to gregm's answer I'm using now:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
This installs the JAR of the project itself to local repository.
Result:
--- maven-jar-plugin:2.3.2:jar (default-jar) # SportyLib ---
Building jar: ...-1.0-SNAPSHOT.jar
--- maven-install-plugin:2.5.2:install (default-install) # SportyLib ---
Installing ...-1.0-SNAPSHOT.jar to .../.m2/repository/.../1.0-SNAPSHOT/...-1.0-SNAPSHOT.jar
Installing .../pom.xml to .../.m2/repository/.../1.0-SNAPSHOT/...-1.0-SNAPSHOT.pom

Not generating OSGI-INF folder

I am new to OSGI.I have been having trouble to get OSGI-INF folder in generated jar file.
I need to have folder structure like as below
META-INF
OSGI-INF
Com.mine.cq
I am using Eclipse and m2e plugin. When I run my project I am getting BUILD SUCCESS. And I am getting the below folder structure in that generated jar file.
META-INF
Com.mine.cq
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>com.mine.cq</groupId>
<artifactId>mineCore</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mineCore</name>
<url>http://maven.apache.org</url>
<properties>
<file.encoding>utf-8</file.encoding>
</properties>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0-alpha-3</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<message>Project must be built with Maven 2.0.7 or higher</message>
<version>2.0.7</version>
</requireMavenVersion>
<requireJavaVersion>
<message>Project must be compiled with Java 5 or higher</message>
<version>1.5.0</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
com.mine.cq.mineCore.*
</Export-Package>
<Import-Package>
*;resolution:=optional,
javax.servlet;version=2.4,
javax.servlet.http;version=2.4
</Import-Package>
<Embed-Dependency>
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Include-Resource>{maven-resources}</Include-Resource>
<Sling-Bundle-Resources>/var/classes</Sling-Bundle-Resources>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.0</version>
<configuration>
<goals>install</goals>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Why OSGI-INF folder is not in the .jar file? I need to set some information in OSGO-INF folder since I have to register my component as a OSGI service.
Please guide me to get it done.
Although being pretty late, I'll post my 2 cents about this issue for future reference.
As already pointed out, you can have the "packaging" of the bundle set to "jar" if you follow the instructions given in Maven bundle plugin documentation.
There is just a little gotcha: with that configuration, you need to explicitly add <exportScr>true</exportScr> inside the plugin configuration in order to properly create the SCR xml file (also remember to adjust manifest location, since in the documentation that piece is absent!).
You can see an example here (that's totally different from yours, but I assume you can easily reduce it on your code, if you're still interested):
<?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.massimobono.karaf.examples</groupId>
<artifactId>user-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<!-- Here you specifiy that you want to use the manifest file generated by maven bundle plugin -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<!-- Here you generate the whole MANIFEST by using maven-bundle-plugin -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions> <!-- make sure this is present -->
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<manifestLocation>${project.build.outputDirectory}/META-INF/</manifestLocation> <!-- make sure this is present! in the example of maven bundle plugin documentation, this piece is NOT present -->
<exportScr>true</exportScr> <!-- be sure to add this line as well -->
<supportedProjectTypes>
<supportedProjectType>jar</supportedProjectType>
<supportedProjectType>bundle</supportedProjectType>
<supportedProjectType>war</supportedProjectType>
</supportedProjectTypes>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<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>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.osgi/org.osgi.service.component.annotations -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
</project>
Your pom.xml needs to have a packaging type of "bundle" rather than "jar". If you want the packaging type to be "jar", use this:
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html#ApacheFelixMavenBundlePlugin%28BND%29-AddingOSGimetadatatoexistingprojectswithoutchangingthepackagingtype
EDIT: Oh! That's only problem one. The other problem is that I don't think you can generate
OSGI-INF with the maven-bundle-plugin. You need to create the OSGI-INF folder yourself within src/main/resources or use a plugin that generates OSGI-INF.
The maven-scr-plugin can generate OSGI-INF, but it's only useful if you are using SCR. Maven SCR Plugin - Not generating OSGI-INF folder

Categories