maven does not change the snapshot jar file in local repository - maven

We config jfrog artifactory successfully and create a pom.xml to build and deploy our basic jar files into it as snapshot. then we configure another project to get those jar files from repository and it did successfully too, then we try to change basic libraries and deploy it again as the same snapshot name, and it did correctly but when we want to get those libraries again, maven does not change the basic libraries in local repository, unless we change the version of the snapshot but we don't want to do it.
deploy pom.xml configuration file
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.2.2</version>
<inherited>false</inherited>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<deployProperties>
<gradle>awesome</gradle>
</deployProperties>
<artifactory>
<includeEnvVars>true</includeEnvVars>
<timeoutSec>60</timeoutSec>
<propertiesFile>publish.properties</propertiesFile>
</artifactory>
<publisher>
<contextUrl>{{ARTIFACTORY_CONTEXT_URL|"http://tls.local:9081/artifactory"}}</contextUrl>
<username>admin</username>
<password>AP5PqkrxgwKVMBeY6wxPYr66R3M</password>
<excludePatterns>*-tests.jar</excludePatterns>
<repoKey>libs-release-local</repoKey>
<snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
</publisher>
<buildInfo>
<buildName>plugin-demo</buildName>
<buildNumber>{{DRONE_BUILD_NUMBER|TRAVIS_BUILD_NUMBER|CI_BUILD_NUMBER|BUILD_NUMBER}}
</buildNumber>
<buildUrl>{{DRONE_BUILD_URL|CI_BUILD_URL|BUILD_URL}}</buildUrl>
</buildInfo>
<licenses>
<autoDiscover>true</autoDiscover>
<includePublishedArtifacts>false</includePublishedArtifacts>
<runChecks>true</runChecks>
<scopes>compile,runtime</scopes>
<violationRecipients>build#organisation.com</violationRecipients>
</licenses>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
third party pom.xml configuration file:
<repository>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://tls.local:9081/artifactory/libs-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
How can we achieve our goal?

first we must configure our jfrog repository's maven snapshot version behavior to unique and check handle releases and handle snapshot and then delete completely our local repository's snapshot

Related

Problems setting up dokka in Maven

I have added the following to my pom.xml, based on this page:
https://github.com/Kotlin/dokka#using-the-maven-plugin
pom.xml
<dependency>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>0.9.19-dev-15</version>
</dependency>
<pluginRepositories>
<pluginRepository>
<id>jcenter</id>
<name>JCenter</name>
<url>https://jcenter.bintray.com/</url>
</pluginRepository>
</pluginRepositories>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>0.9.19-dev-15</version>
<executions>
<execution>
<phase>pre-site</phase>
<goals>
<goal>dokka</goal>
</goals>
</execution>
</executions>
<configuration>
<dokkaPlugins>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>kotlin-as-java-plugin</artifactId>
<version>0.9.19-dev-15</version>
</plugin>
</dokkaPlugins>
</configuration>
</plugin>
When I run the project, I get the following errors:
Dependency 'org.jetbrains.dokka:dokka-maven-plugin:0.9.19-dev-15' not found
Plugin 'org.jetbrains.dokka:dokka-maven-plugin:0.9.19-dev-15' not found
Can someone help out with this configuration? Thanks in advance.
For this version add the Kotlin Dev Maven repository to you project:
<repositories>
<repository>
<id>k-dev</id>
<name>K-dev</name>
<url>https://dl.bintray.com/kotlin/kotlin-dev/</url>
</repository>
</repositories>
You can see the URL of the repository for this library page on the Maven central:
Note: this artifact is located at Kotlin Dev repository (https://dl.bintray.com/kotlin/kotlin-dev/)

Not able to download Jars from nexus

I have project A which is dependency of project B. Since project B should get latest jar version of Project A . I purge Project A jar from local so Project B will get Project A jar from nexus since it has been deleted from local.
I can see in the logs that It can download jar from nexus . but still getting pom for jar is missing
below are the logs
Downloading from : ://10.245.240.43:8081/nexus/repository/maven-snapshots/com/sgl/smartpra/master/model/smartpra-master-model/0.0.1-SNAPSHOT/smartpra-master-model-0.0.1-20191126.094645-53.jar
[INFO] Downloaded from : ://10.245.240.43:8081/nexus/repository/maven-snapshots/com/sgl/smartpra/master/model/smartpra-master-model/0.0.1-SNAPSHOT/smartpra-master-model-0.0.1-20191126.094645-53.jar (183 kB at 1.7 MB/s)
The POM for com.sgl.smartpra.master.model:smartpra-master-model:jar:0.0.1-20191126.094645-53 is missing, no dependency information available
You can see that it can able to pull jars from nexus still getting artifact missing.
I added maven plugin to perge dependent jars from local so it will pull latest jar from nexus
refer Below snippet
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>purge-local-dependencies</id>
<phase>process-sources</phase>
<goals>
<goal>purge-local-repository</goal>
</goals>
<configuration>
<includes>
<include>com.sgl.smartpra.global.master.model:smartpra-global-master-model</include>
<include>com.sgl.smartpra.batch.global.model:smartpra-batch-global-model</include>
<include>com.sgl.smartpra.master.model:smartpra-master-model</include>
<include>com.sgl.smartpra.exception.txn.model:smartpra-exception-txn-model</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
Below is nexus repository configuration for downloading jars from nexus
Please check below code
refer Below snippet
I have project A which is dependency of project B. Since project B should get latest jar version of Project A . I purge Project A jar from local so Project B will get Project A jar from nexus since it has been deleted from local.
<repositories>
<repository>
<id>maven-group</id>
<url>**strong text**/10.245.240.43:8081/nexus/repository/maven-group/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>

How do I include a Maven plugin from a local repository?

I have a custom plugin that compresses files that I need to include in my maven build. So I have included this plugin in my pom.xml:
<build>
// Other tags
<plugin>
<groupId>someGroupId</groupId>
<artifactId>somePlugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Since it is a custom plugin, it is not available in any public Maven repository. So whenever I try to build, I get an error message saying:
Failed to read artifact .....
even though I have added it to my local repository. How can I refer to this plugin that is in my local repository?
If you mean local repository in the classic sense, make sure that you installed your plugin jar correctly. Install it to your local repository again with the following command:
mvn install:install-file -Dfile=/some/path/somePlugin.jar -DgroupId=someGroupId -DartifactId=somePlugin -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true
You should then be able to use your plugin in your Maven build.
If you mean local in the sense of some locally hosted repository, you need to specify the repository containing your artifact as a pluginRepository. Add the following to the top level of your pom.xml:
<pluginRepositories>
<pluginRepository>
<id>some-repo</id>
<name>Some Repository</name>
<url>http://some.host/some/path</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

Not downloading converted OSGI bundles from custom p2 site using Maven

My project is in RCP. The product is created using Maven. My RCP project depends on third party jars. Currently we are adding these jars in plugin.xml "runtime". So whenever there is change in third party jars, we have to update the plugin.xml file.
Now we are changing the process by converting the third party jars in to OSGI bundle using maven then create p2 site and while building, add the third party OSGI bundles in classpath.
We have done the conversion to OSGI bundle and creating p2 site. But when we are adding it in repository, the converted third party OSGI bundles are not always get download.
We have added below code in pom.xml to convert in to OSGI bundle and create p2:site:
<build>
<plugins>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifacts>
<artifact><id>com.test.proj:proj-jar1:6.01.00-SNAPSHOT</id></artifact>
<artifact><id>com.test.proj:proj-jar2:6.01.00-SNAPSHOT</id></artifact>
<artifact><id>com.test.proj:proj-jar3:1.1</id></artifact>
<artifact><id>com.test.proj:proj-jar4:1.0</id></artifact>
<artifact><id>com.test.proj:proj-jar5:1.0</id></artifact>
<artifact><id>com.test.proj:proj-jar6:6.01.00-SNAPSHOT</id></artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory>
<webApp>
<contextPath>/site</contextPath>
</webApp>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>0.22.0</version>
<extensions>false</extensions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>reficio</id>
<url>http://repo.reficio.org/maven/</url>
</pluginRepository>
</pluginRepositories>
To download while build we have added:
<repositories>
<repository>
<id>extJars</id>
<url>http://localhost:8080/site/</url>
<layout>p2</layout>
</repository>
</repositories>
When we call "mvn install" it is not downloading the jars from "http://localhost:8080/site" every time.
So please let me know what is going wrong in my pom.xml
Any help is appreciated. Thanks
In Maven you cannot build something and then depend on it dynamically in one reactor. This way the build dependencies cannot be computed. You either have to
Build your p2 update site
Build the rest
or you should use something the m2e people call wrapper bundle. They used it in this pom.xml.

Maven Include dependencies in Executable Jar

Am new to Maven...
Trying to create a simple applet.
Include dependencies for the applet.
For this I have tried :
<repository>
<id>lib</id>
<name>lib</name>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>file://${project.basedir}/lib</url>
</repository>
I have these files included in the lib folder under my project structure.
this lib contains couple of jar files and a JNI dll which I need to use in my applet.
Is there any better option to create repository than the above,Kindly share?
Packaging applet jar with dependencies.
For this I have tried :
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
I expect the above to wrap my dependencies into one single jar, but its not been the case.
the generated jar file size doesnt contain the dependency jar files.(I can say coz the size of the jar file remains unchanged for both jars with and without dependencies are same)
Am I in the right way of doing things with Maven?
Take look at shade plugin, this plugin creates executable "uber jar" or if you realy need something really complicated assembly plugin.

Resources