I am developing an eclipse plugin, Where i need to use the tools.jar as an dependency.As we know eclipse does not take normal jar as dependencies. so i tried to change the jar as osgi bundle. But the generated osgi bundle does not contain the com.sun packages inside.
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.7.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
I tried to bundle all the dependencies given in the 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nuwaza.aqua</groupId>
<artifactId>osgi-tool-bundle</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.7.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<Bundle-SymbolicName>osgi-tool-bundle</Bundle-SymbolicName>
<Bundle-Name>osgi-tool-bundle</Bundle-Name>
<Bundle-Version>1.0.0</Bundle-Version>
<Export-Package>*</Export-Package>
<Private-Package>com.nuwaza.aqua.bundle</Private-Package>
<Bundle-Activator>com.nuwaza.aqua.bundle.Activator</Bundle-Activator>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Dependency>*;scope=compile|runtime|system</Embed-Dependency>
<Embed-Directory>target/dependency</Embed-Directory>
<Embed-StripGroup>true</Embed-StripGroup>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<profiles>
<profile>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<osgi-version-qualifier>qualifier</osgi-version-qualifier>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<!-- PDE does not honour custom manifest location -->
<manifestLocation>META-INF</manifestLocation>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
The generated bundle only contains org.osgi packages not com.sun packages. I even included system scope in <Embed-Dependency>*;scope=compile|runtime|system</Embed-Dependency>.
What am i missing ?
Related
I have a spring boot project (Project A) created which do contains commonly used methods and I have hosted this project in GitHub deployed artifacts and used it as a dependency in other projects (Project B, C ..) to reuse those methods. I have one common method created in Project A which does read the value from the application properties file which works fine locally but when I deploy the artifacts to GitHub and use it as a dependency it is not able to read the value from an application properties file and read as null. Maybe I am not including the properties files while deploying artifacts for Project A correctly.
pom.xml (Project A)
<?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 https://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>2.6.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.abc</groupId>
<artifactId>api-authenticator</artifactId>
<version>1.0.2</version>
<name>API Authenticator</name>
<description>Project to authenticate API usage</description>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Staging Repository</name>
<url>file://${project.build.directory}/${version}</url>
</repository>
</distributionManagement>
<properties>
<github.global.server>github</github.global.server>
<java.version>11</java.version>
<java-jwt.version>3.16.0</java-jwt.version>
<jwks-rsa.version>0.18.0</jwks-rsa.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>${java-jwt.version}</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>jwks-rsa</artifactId>
<version>${jwks-rsa.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>resources</directory>
<targetPath>src/main/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}</outputDirectory>
<branch>refs/heads/${version}</branch>
<includes>
<include>**/*</include>
</includes>
<merge>true</merge>
<repositoryName>api-authenticator</repositoryName>
<repositoryOwner>me</repositoryOwner>
<server>github</server>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<files>
<file>
${project.basedir}/src/main/resources/application.properties
</file>
</files>
<altDeploymentRepository>
internal.repo::default::file://${project.build.directory}/${version}
</altDeploymentRepository>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm a computer science student and I'm currently making my first steps in using JEE. To retry an example of my study material, I tried to build a web-application using IntelliJ Community. As there is no offical possibility to do so with the community version, I tried to use maven following this tutorial: https://www.shortn0tes.com/2017/01/tutorial-intellij-idea-community.html
Now I get an error about the dependency injection of javax in the pom.xml:
Dependency 'javax:javaee-api:6.0' not found
Is there anything that I need to add/configure in my IntelliJ IDE? I know that the tutorial is maybe not super modern anymore, but I'd just like to follow the example of my university material.
Thank you very much!
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>
<groupId>org.example</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>test Maven Webapp</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.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>test</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8888</port>
<path>/</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I am trying create 2 zip files one for testing and other for production.
pom.xml looks like below.
<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.abc</groupId>
<version>1.0.0</version>
<artifactId>abc</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>a.abc</groupId>
<artifactId>abc1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>a.abc</groupId>
<artifactId>abc2</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>a.abc</groupId>
<artifactId>abc3</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>b.xyz</groupId>
<artifactId>xyz1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>b.xyz</groupId>
<artifactId>xyz2</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>b.xyz</groupId>
<artifactId>xyz3</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>app-${project.version}</finalName>
</build>
<profiles>
<profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<!-- <finalName>${project.name}</finalName> -->
</configuration>
<executions>
<execution>
<id>app-package-test</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>src/main/assembly/test-descriptor.xml</descriptor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>a.abc</groupId>
<artifactId>abc1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>a.abc</groupId>
<artifactId>abc2</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>a.abc</groupId>
<artifactId>abc3</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>production</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<finalName>${project.name}</finalName>
</configuration>
<executions>
<execution>
<id>app-package-production</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>src/main/assembly/production-descriptor.xml</descriptor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>b.xyz</groupId>
<artifactId>xyz1</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>b.xyz</groupId>
<artifactId>xyz2</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>b.xyz</groupId>
<artifactId>xyz3</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
But when I run mvn clean install it will build both profile since
<activation>
<activeByDefault>true</activeByDefault>
</activation>
But final bundled zip contains both dependencies of profile test and production
I need zip generated by profile test to have dependencies related to test profile and zip generated by profile production to have dependencies related to production profile.
Anyone know why this is happening?
I created maven artifact, that have dependencyies on gson and ok3http.
The pom.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.test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>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>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
</dependencies>
<build>
<finalName>testConnect</finalName>
<plugins>
<!-- download source code in Eclipse-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</plugin>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Copy project dependency -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- exclude junit, we need runtime dependency only -->
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now I send it to local repository (later will send to Maven central) and I want people to be able to use my artifact in their pom files like:
<dependency>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
</dependency>
It builds ok, but when I try to use it, it throws error that it can not found gson and ok3http.
If I add also:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
It started to work. Is it possible that people can add dependency to my artifact only and other dependencies will add automatically or something like this?? Thanks!
Although will be very thankful if you give me the right documentations how to send my code to maven repo.
I have a multi-module maven project where module A/B/C depends on module D.
Plugin maven-surefire-plugin is used for test phrase.
However,
mvn clean package
doesn't generate surefire-reports under **/target/
And
mvn clean; mvn package
could generate surefire-reports as expected.
This confused me a lot. Although the workaround for me is simply splitting to two mvn commands but I would like to know why?
Versions:
maven 3.3.3
jdk 1.7.0
maven-surefire-plugin 2.14
Root 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>
<groupId>org.jzako.test</groupId>
<artifactId>FeedbackSystem</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>FeedbackSystem</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>ModuleA</module>
<module>ModuleB</module>
<module>ModuleC</module>
<module>Utility</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<forkMode>never</forkMode>
</configuration>
</plugin>
</plugins>
</build>
</project>
Module A Pom:
<?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>org.jzako.test</groupId>
<artifactId>FeedbackSystem</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>org.jzako.test</groupId>
<artifactId>ModuleA</artifactId>
<version>1.0-SNAPSHOT</version>
<name>ModuleA</name>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.jzako.test.main.LightweightFeedbackStatisticsMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/../conf/dev</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>${basedir}/../conf/dev</directory>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.jzako.test</groupId>
<artifactId>Utility</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Multi-module Relationship
Module A/B/C depends on Utility Module and no dependencies among Module A/B/C.
Update:
It seems everything's fine for a single maven module projects. Something related to the multi-modules?