Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven system scope for testing purposes

I wrote a little framework for testing microservices. Now I packed my contracts into a jar which will be used to test my framework, but i don't want to deploy them to our nexus. so my pom contains

<dependency>
    <groupId>mycompany.testframework</groupId>
    <artifactId>test.dummy-contract</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/test/resources/contract-dummy.jar</systemPath>
</dependency>

now if i want to use the framework in another project (using gradle) I get this error message:

Processing of C:\Users\dam\.gradle\caches\modules-2\files-2.1\mycompany.testframework\TestFramework\0.0.1-SNAPSHOT\5859a002118d47b4237425d25dfc79ea1d7eb829\TestFramework-0.0.1-SNAPSHOT.pom failed:
'dependencies.dependency.systemPath' for mycompany:test.dummy-contract:jar must specify an absolute path but is ${project.basedir}/src/test/resources/contract-dummy.jar in mycompany.testframework:TestFramework:0.0.1-SNAPSHOT

I need the dependency for my jenkins test and build but not for "delivery". any suggestions?

like image 368
David Avatar asked Jun 09 '26 20:06

David


1 Answers

I resolved it by adding the dependency to a profile wich only will be used for the test-framework and on the jenkins

<profiles>
    <profile>
        <id>test-dummy</id>
        <activation>
            <file>
                <exists>${project.basedir}/src/test/resources/contract-dummy.jar</exists>
            </file>
        </activation>
        <dependencies>
            <dependency>
                <groupId>de.company.testframework</groupId>
                <artifactId>test.dummy-contract</artifactId>
                <version>1.0</version>
                <scope>system</scope>
                <systemPath>${project.basedir}/src/test/resources/contract-dummy.jar</systemPath>

                <optional>true</optional>
            </dependency>
        </dependencies>
    </profile>
</profiles>
like image 197
David Avatar answered Jun 11 '26 11:06

David