Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<excludedArtifacts> not working as expected #435

Open
tomcruise81 opened this issue Nov 28, 2022 · 5 comments
Open

<excludedArtifacts> not working as expected #435

tomcruise81 opened this issue Nov 28, 2022 · 5 comments

Comments

@tomcruise81
Copy link

  • Java: 1.8.0_301
  • Maven: 3.8.6
  • JMeter-Maven-Plugin: 3.6.1

This might be related to #419, but I'm not 100% sure on that.

I've tried to supply <testPlanLibraries> with a number of <artifact> entries.

Unfortunately, it brings in ALL transitive dependencies from those artifacts, including those at test scopes.

So to try and alleviate that, I attempted to exclude the test scoped transitive dependencies via <excludedArtifacts>.

It appears as if <testPlanLibraries> takes precedence over <excludedArtifacts>, because NONE of the <exclusion> entries that I supplied under <excludedArtifacts> were actually excluded.

@tomcruise81
Copy link
Author

tomcruise81 commented Nov 28, 2022

The only thing that I've gotten to remotely work is to follow the advice of https://stackoverflow.com/a/42345443/6262804 and set

<downloadExtensionDependencies>false</downloadExtensionDependencies>

I was able to get the full dependency list via

mvn com.github.ferstl:depgraph-maven-plugin:4.0.2:for-artifact -Dartifact=$TARGET_GAV_COORDINATES -DgraphFormat=text -DclasspathScope=compile -DshowGroupIds=true -DshowVersions=true

Then I explicitly add all of my dependencies as <artifact> entries.

Obviously, this isn't ideal as with each time we upgrade our actual desired libraries, we'll have to go through multiple steps to keep all the transitive dependencies up to date, whereas Maven can do that kind of stuff for us.

@ratoaq2
Copy link

ratoaq2 commented Mar 13, 2023

@ratoaq2
Copy link

ratoaq2 commented Mar 13, 2023

Looking at the source code, you can use ignoredArtifacts... not sure if this is documented:

<ignoredArtifacts>
  <artifact>org.hibernate.orm:hibernate-core:6.1.6.Final</artifact>
</ignoredArtifacts>

@tomcruise81
Copy link
Author

It looks like the root of my problems is:

In other words, because "JMeter tests use test, provided, and compile-scoped dependencies", and the resolveTestDependenciesAndCopyWithTransitivity is reused, that method isn't flexible enough to handle ONLY bringing in compile dependencies related to the testPlanLibraries, and ALL transitive dependencies from ALL scopes for the other types of JMeter dependencies...

@YerayBrito
Copy link

as we are currently facing the same => there is a possibility to solve that by combining a set of plugins and a small copy script and binding this to maven phases, e.g. a POM to copy Faker and the Maria driver lib

    <profiles>
        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <e2e-stage>dev</e2e-stage>
            </properties>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>com.github.javafaker</groupId>
            <artifactId>javafaker</artifactId>
            <version>1.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <version>3.1.4</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>3.6.1</version>
                <executions>
                    <execution>
                        <id>default-cli</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>configure</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jmeter-tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jmeter-check-results</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>results</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <generateReports>true</generateReports>
                    <customPropertiesFiles>
                        <file>${basedir}/src/test/resources/${e2e-stage}.properties</file>
                    </customPropertiesFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.6.0</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeGroupIds>org.slf4j</excludeGroupIds>
                            <excludeGroupIds>net.java.dev.jna</excludeGroupIds>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>copy-to-jmeter-libs</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>${basedir}/scripts/copy-dependencies.sh</executable>
                </configuration>
            </plugin>
        </plugins>
    </build>

the copy script to use to call by the exec goal

#!/bin/sh

target=$(jq -r '.configurations[0].jmeterDirectoryPath' target/config.json)
cp -av target/dependency/* "$target/lib"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants