Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Azure by (7k points)
edited by
We have one project which has files shared across several others so the maven compile for that project creates a .jar file. When I compile the micro services on my laptop, they each have a dependency on the jar file in my repo. And they pick up the related dependency and the Maven build.​

But, the code build pipeline does not maintain a local repo. So when I try to do “mvn clean install” on each micro service they cannot locate shared.jar and the build fails.​

1 Answer

0 votes
by (31.9k points)
edited by

Have a separate pipeline to build the dependency which deploys it to an Azure feed:

variables:

        - name: mavenRepoURL

          value: 'https://myorg.pkgs.visualstudio.com/myproject/_packaging/myfeed/maven/v1'

        - task: DownloadSecureFile@1

          name: mvnSettings

          displayName: 'Download Maven settings'

          inputs:

            secureFile: 'maven-azuredevops-settings.xml'

        - task: MavenAuthenticate@0

          displayName: Maven Authenticate Artifacts

          inputs:

            artifactsFeeds: 'myfeed'

        - task: Maven@3

          inputs:

            mavenPomFile: 'pom.xml'

            options: '-X -B -s $(mvnSettings.secureFilePath) -DWHERE="AzureDevops" -DremoteRepositories=$(mavenRepoUrl) clean deploy -U'

            mavenAuthenticateFeed: true

            publishJUnitResults: true

            testResultsFiles: '**/TEST-*.xml'

Add dependency to pom for the project using it as normal and with Azure feed configured as well

<dependency>

            <groupId>com.foobar.blah</groupId>

            <artifactId>artifactId</artifactId>

            <version>2.0.2</version>

        </dependency>

 

        <profile>

            <id>AzureDevops</id>

            <activation>

                <property>

                    <name>WHERE</name>

                    <value>AzureDevops</value>

                </property>

            </activation>

            <properties>

            </properties>

            <distributionManagement>

                <repository>

                    <id>myfeedname</id>

                    <url>https://myorg.pkgs.visualstudio.com/_packaging/myfeed/maven/v1</url>

                    <releases>

                        <enabled>true</enabled>

                    </releases>

                    <snapshots>

                        <enabled>true</enabled>

                    </snapshots>

                </repository>

            </distributionManagement>

        </profile>

Want to become Azure Developer, check out this Azure Tutorial.

Want more insights on Azure, visit the Azure Training page.

Related questions

0 votes
1 answer
asked Nov 22, 2020 in Azure by Justin (7k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...