Hi,

I just tried to add a dependency by inserting the reference found here ( https://mvnrepository.com/artifact/com.opencsv/opencsv/3.8) into the pom.xml of the project (using Axon Ivy Designer 6.0.4)

I tried to build it with "mvn install" in the command line and got an error that the library is missing (CSVWriter cannot be resolved to a type)

Executing the following command shows me that the artifact ist downloaded.

"mvn dependency:get -Dartifact=com.opencsv:opencsv:3.8"

[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building xapf_customer 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:2.8:get (default-cli) @ xapf_customer --- [INFO] Resolving com.opencsv:opencsv:jar:3.8 with transitive dependencies [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.068 s [INFO] Finished at: 2016-10-10T18:35:23+02:00 [INFO] Final Memory: 9M/22M [INFO] ------------------------------------------------------------------------

Adding the library in the Axon Ivy Environment removes the errors in the IDE. But the error still exits if I want to execute a "maven install".

Is there anything I'm missing?

BR and thx, Gerald

POM File: <?xml version="1.0" encoding="UTF-8"?> <project xsi:schemalocation="http://maven.apache.org/POM/4.0.0 &lt;a href=" http:="" maven.apache.org="" xsd="" maven-4.0.0.xsd""="">http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelversion>4.0.0</modelversion> <groupid>xapf_customer_csv_export</groupid> <artifactid>xapf_customer_csv_export</artifactid> <version>1.0.0-SNAPSHOT</version> <packaging>iar</packaging> <description>Based on Template Version 1.1.0</description> <dependencies> <dependency> <groupid>xapf_persistence</groupid> <artifactid>xapf_persistence</artifactid> <version>[1.0.0-SNAPSHOT,)</version> <type>iar</type> </dependency> <dependency> <groupid>ch.soreco.xapf.engine</groupid> <artifactid>ch.soreco.xapf.engine</artifactid> <version>[3.0.0-SNAPSHOT,)</version> <type>iar</type> </dependency> <dependency> <groupid>ch.soreco.xapf.masterdata</groupid> <artifactid>ch.soreco.xapf.masterdata</artifactid> <version>[3.0.0-SNAPSHOT,)</version> <type>iar</type> </dependency> <dependency> <groupid>xapf_archive_d3</groupid> <artifactid>xapf_archive_d3</artifactid> <version>[1.0.0-SNAPSHOT,)</version> <type>iar</type> </dependency> <dependency> <groupid>com.opencsv</groupid> <artifactid>opencsv</artifactid> <scope>compile</scope> <type>jar</type> <version>3.8</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>com.axonivy.ivy.ci</groupid> <artifactid>project-build-plugin</artifactid> <version>6.0.0</version> <extensions>true</extensions> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> </plugin> </plugins> </build> </project>

asked 10.10.2016 at 18:45

Gerald's gravatar image

Gerald
(suspended)
accept rate: 0%

edited 11.10.2016 at 08:35

Could you include your pom file?

(11.10.2016 at 03:49) Hap Em Hap%20Em's gravatar image

The thing is, that only IAR maven-dependencies are included in the projects classpath on the engine. There is currently no built in support to include normal JAR dependencies in a project and auto-download them when a project is deployed to an engine.

A simple work-around is to add the maven-dependency-copy plugin to your POM.xml. It will copy JAR dependencies to a directory in your project and you can add it to the classapth:

<build>
<plugins>
...
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.10</version>
        <executions>
            <execution>
                <id>copy.maven.dependencies</id>
                <goals><goal>copy</goal></goals>
                <phase>generate-resources</phase>
                <configuration>
                    <outputDirectory>lib</outputDirectory>
                    <artifactItems>
                        <artifactItem>
                            <groupId>com.opencsv</groupId>
                            <artifactId>opencsv</artifactId>
                            <version>3.8</version>
                        </artifactItem>
                    </artifactItems>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>
</build>

With this configuration you can run mvn clean generate-resources, refresh your project in the workspace afterwards and add the JARs in the lib directory to your classpath via: Java Perspective -> Right click on Jar -> build path -> add to build path

link

answered 11.10.2016 at 09:04

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

edited 11.10.2016 at 09:09

Hi, thx for the answer. This works well and I have the lib in the local project folder. But I still cannot execute a "mvn compile" (I want to run the build process on a Jenkins later).

I added the lib in Axon Ivy and it tells me that there are no longer missing references. But, as mentioned, the command line process cannot find it. Do I need to define the local library somewhere else for Maven?

Thx in advance,

Gerald

(11.10.2016 at 13:19) Gerald Gerald's gravatar image

Try to use the latest project-build-plugin:6.3.0 as it has several improvements in the classpath handling: http://axonivy.github.io/project-build-plugin/release/6.3/index.html

If the commandline execution still does not work. Run mvn clean install -X and share the debug output with us.

(11.10.2016 at 15:35) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

Another way to use maven-dependency-plugin suggestested by Emmanuel is this:

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>Copy-dependency-PROD</id>
            <phase>validate</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration combine.self="override">
            <outputDirectory>${basedir}/lib</outputDirectory>
            <stripVersion>true</stripVersion>
            <includeScope>compile</includeScope>
            <excludeGroupIds>org.powermock, org.hamcrest,org.mockito, junit, org.objenesis, org.sonarsource.java</excludeGroupIds>
            <excludeArtifactIds>jsf-api, javase, commons-codec</excludeArtifactIds>
            <excludeTypes>iar</excludeTypes>
            <excludeTransitive>true</excludeTransitive>
            </configuration>
        </execution>
    </executions>
</plugin>

This will include any jar dependency to the lib directory and is packged when running maven. In Desinger it still needs to be linked manually once by right clicking on the project, "Build Path.." -> Configure Build Path -> Add External JARs.

link

answered 19.09.2017 at 11:45

adamf's gravatar image

adamf
(suspended)
accept rate: 25%

ok basically I like this approach. But I think the exclusions of test frameworks is not intuitive. I always suggest to create an extra project for test cases (Even tough standard maven handles it different). So you will never have code deps to test frameworks and therefore you do no need to exclude them while copying POM deps. If test and prod code is in the same projects, chances are ways to high that test code at some point of time will leak into production without notice...

(25.09.2017 at 04:15) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

yeah, I already noticed that src and src_test are copied compiled into classes. Wonder if things get easier if ivy project conforms to standard maven project directory layout (src/main/java, src/test/java, src/main/resources, ..). Great about TDD is that you have less chance of introducing regressions or bugs. When having tests separate there is less motivation to keep them up to date and increased complexity for continuous integration.

(25.09.2017 at 08:50) adamf adamf's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×22

Asked: 10.10.2016 at 18:45

Seen: 9,830 times

Last updated: 25.09.2017 at 08:50