bamboo java specs with extra maven repository - bamboo

I use bamboo 7.2.2 as a CI engine with java specs. I am trying to build some reusable bamboo stages/jobs/tasks. Develop once, publish to a private maven repository, and then reuse them in various other bamboo plans by defining the dependency in the pom.xml.
As the library is published in a private repository, I have to define the repository in the pom.xml.
The problem is that at runtime, bamboo merges my pom.xml with some template of its own and removes the repository definition.
Is there any other option to define multiple maven repositories for bamboo java specs?

No way other than modifying the template pom.xml on the Bamboo server.
Note however, that you'll have to wait for 24 hours (the Maven default) to see your changes in the common specs library. Unless of course, you bump the common specs version and manually update the template pom.xml again.

We do exactly what you describe and don't appear to have any problems. We're able to use our custom shared classes in our Bamboo Specs. This is the pom.xml for one of our apps.
<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>
<groupId>com.atlassian.bamboo</groupId>
<artifactId>bamboo-specs-parent</artifactId>
<version>7.2.3</version>
<relativePath />
</parent>
<groupId>com.example.someapp</groupId>
<artifactId>bamboo-specs</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>nexus</id>
<name>Internal Nexus Repository</name>
<url>https://mvn.example.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>custom-bamboo-specs</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
The only weird behaviour we have is that we can't have two apps building with different versions of this custom library - Bamboo gets really confused until we bring them all in line. Other than that, it works.
Bamboo version: 7.2.10

Related

Oracle jdbc jar unable to down load in maven plugin

[WARNING] The POM for com.oracle:ojdbc7:jar:12.1.0 is missing, no dependency information available
<!-- Oracle JDBC driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>
<!-- HikariCP connection pool -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.6.0</version>
</dependency>
The latest release of the oracle jdbc driver is available in maven central since a few days (september 2019, announced at Oracle CodeOne), there is no longer a need to install it locally or add obscure other repositories.
See https://medium.com/oracledevs/oracle-jdbc-drivers-on-maven-central-64fcf724d8b
The coordinates are
<!-- https://mvnrepository.com/artifact/com.oracle.ojdbc/ojdbc8 -->
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
ojdbc7 is absent in the maven central repository
You need to download jar from oracle.com.
Currently it can be downloaded here. Registration is needed.
https://www.oracle.com/database/technologies/jdbc-upc-downloads.html
Then import ojdbc7.jar into your local maven repository with the following command
mvn install:install-file -Dfile=ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar -DgeneratePom=true
Alternatively, if your team has it's own remote maven repository, import it there.
edit: fixed mvn command and link
Add repository to your build and download:
See on mvnrepository.com
<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.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>HandChina-RDC</id>
<name>HandChina RDC</name>
<url>http://nexus.saas.hand-china.com/content/repositories/rdc/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
</dependencies>
</project>

maven setup another repository for certain dependency

I have Maven2 project. All dependencies except one are downloaded from public repository http://repo.maven.apache.org/maven2/.
But I have 1 dependency which I need to download from internal company's repository (we use Sonatype Nexus to store this dependency).
Also, I don't want to create full copy of public repo on my internal repo.
At this moment I have in pom.xml:
<url>http://maven.apache.org</url>
and
<repositories>
<repository>
<id>thirdparty</id>
<url>http://<my_nexus_server_ip>:8081/nexus/content/repositories/thirdparty</url>
</repository>
</repositories>
So, during build I see a lot of trash messages (in this case first line is a trash):
Downloading: http://<my_nexus_server_ip>:8081/nexus/content/repositories/thirdparty/ant/ant/1.6.5/ant-1.6.5.pom
Downloading: http://repo.maven.apache.org/maven2/ant/ant/1.6.5/ant-1.6.5.pom
Downloaded: http://repo.maven.apache.org/maven2/ant/ant/1.6.5/ant-1.6.5.pom (861 B at 3.2 KB/sec)
I want to clearly point Maven for which dependency it have to use internal repository and ignore it for others dependencies (and point that for others dependencies Maven2 have to use public repository).
Could you please help to implement such behavior in Maven?
Thanks In Advance!
According to this answer, it is not possible to set a specific repository for for some of the declared dependencies.
You need to configure the public repository group in Nexus to be used the only one in your Maven builds like the following:
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
You have to setup a separate repository in nexus like you described a repo called ThirdParty and add this repository into the configuration of the public repository group. Furthermore you need to upload the one dependency into that particular repository. Apart from that you should have to use the release and SNAPSHOT repository which means you need to configuration your distributionManagement accordingly in your company master pom file.

ivy - why is trying to download yyyy.bundle and can I avoid that?

We recently transformed a maven pom to ivy but are getting this error for many things(not all things):
[NOT FOUND ] org.apache.geronimo.specs#geronimo-javamail_1.4_spec;1.7.1!geronimo-javamail_1.4_spec.bundle (11649ms)
The only difference between the pom files that work and don't is there a package element with the value "bundle".
Maven is working fine. How can we get ivy working as it gets the pom and just really needed to download the jar artifact.
More info, I changed my ivysettings so it ends in .jar instead of [ext] like so
This workardoun worked but I am worried now source downloads won't work anymore. Unfortunately, I don't control the poms in the repository that specify bundle in the packaging attribute. Is there a way to override certain things in ivy so I can fix all these and not use my temporary workaround?
I copied from the pom in nexus for that url which is the following and notice packaging is bundle
<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>
<groupId>org.apache.geronimo.genesis</groupId>
<artifactId>genesis-java5-flava</artifactId>
<version>2.0</version>
</parent>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
<packaging>bundle</packaging>
<name>JavaMail 1.4</name>
<version>1.7.1</version>
<description>Javamail 1.4 Specification</description>
<url>
http://geronimo.apache.org/maven/${siteId}/${version}
</url>
<distributionManagement>
<site>
<id>apache-website</id>
<url>${site.deploy.url}/maven/${siteId}/${version}</url>
</site>
</distributionManagement>
The pom that brings that in is cxf-bundle which I depend on. The dependency in the cxf-bundle is
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
<version>1.7.1</version>
<scope>compile</scope>
</dependency>
thanks,
Dean
Darnit, I copied the example on the ivy site which downloads an older version that has this bug
https://issues.apache.org/jira/browse/IVY-899
The newest version works just fine.

java.net maven repo - JMS artifact missing

I just created a new Maven project using the default archetype and added the following dependency to my POM file.
<dependencies>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Realizing that the Sun's JARs are not on Maven central due to licensing issues, I added
the following Maven repo to my POM (I know this is bad practice though and that it needs to be added to a settings.xml)
<repositories>
<repository>
<id>Repo ID</id>
<layout>default</layout>
<name>Java.net Maven repo</name>
<releases>
<enabled>true</enabled>
</releases>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
I still see this error in my POM file.
"Missing artifact javax.jms:jms:jar:1.1:compile"
Does anyone here know what else needs to be done in addition to the config I already have?
Realizing that the Sun's JARs are not on Maven central due to licensing issues, I added
the following Maven repo to my POM
Yeah, but http://download.java.net/maven/2/javax/ doesn't have the jms artifact...
The good news is that the JBoss Nexus repository does have it:
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
If you just want the jms artifact and don't want to add the whole repo, you can do the following:
wget https://repository.jboss.org/nexus/content/groups/public/javax/jms/jms/1.1/jms-1.1.jar
mvn -e install:install-file -Dfile=./jms-1.1.jar -DartifactId=jms -DgroupId=javax.jms -Dversion=1.1 -Dpackaging=jar
In fact the real solution for this issue is to use the jms-api-1.1-rev-1.jar artifact available on Maven Central : http://search.maven.org/#artifactdetails%7Cjavax.jms%7Cjms-api%7C1.1-rev-1%7Cjar

How to specify a repository for a dependency in Maven

In projects with several dependencies and repositories, the try-and-error approach of Maven for downloading dependencies is a bit cumbersome and slow, so I was wondering if there is any way to set an specific repo for some declared dependencies.
For example, I want for bouncycastle to check directly BouncyCastle's Maven repo at http://repo2.maven.org/maven2/org/bouncycastle/ instead of official Maven.
Not possible. Maven checks the repositories in their declaration order until a given artifact gets resolved (or not).
Some repository manager can do something approaching this though. For example, Nexus has a routes feature that does something equivalent.
I have moved libraries from 3rd party repositories to their own project and included this project as first module in my base project:
base/pom.xml
...
<modules>
<module>thirdparty</module>
<module>mymodule</module>
...
</modules>
base/thirdparty/pom.xml:
...
<artifactId>thirdparty</artifactId>
<packaging>pom</packaging>
<repositories>
<repository>
<id>First thirdparty repository</id>
<url>https://...</url>
</repository>
...
</repositories>
<dependencies>
<dependency>
<!-- Dependency from the third party repository -->
</dependency>
....
</dependencies>
base/mymodule/pom.xml:
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>thirdparty</artifactId>
<version>${project.version}</version>
<type>pom</type>
</dependency>
...
</dependencies>
This will ensure that the libraries from the thirdparty repository are downloaded into the local repository as soon as the root project is build. For all other dependencies the repositories are not visible and therefore not included when downloading.
This post could be very old but might be useful to someone. I specified the two repositories in pom.xml like below and it worked.
<repositories>
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
<repository>
<id>Default</id>
<name>All apart from Aspose</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>