0

I used the https://github.com/jottinger/owlapi-tutorial as base to build this maven file, for a OWL ontology API:

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <!-- Downloaded from https://github.com/jottinger/owlapi-tutorial -->
    <groupId>.</groupId>
    <artifactId>TestJava</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>net.sourceforge.owlapi</groupId>
                <artifactId>owlapi-distribution</artifactId>
                <version>[4.0.2,4.9.9)</version>
            </dependency>
            <dependency>
                <groupId>net.sourceforge.owlapi</groupId>
                <artifactId>owlapi-rio</artifactId>
                <version>[4.0.2,4.9.9)</version>
            </dependency>
            <dependency>
                <groupId>net.sourceforge.owlapi</groupId>
                <artifactId>jfact</artifactId>
                <version>4.0.2</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.7.7</version>
            </dependency>
            <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>[6.9.8,)</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>net.sourceforge.owlapi</groupId>
            <artifactId>owlapi-distribution</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.owlapi</groupId>
            <artifactId>owlapi-rio</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.owlapi</groupId>
            <artifactId>jfact</artifactId>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${basedir}/src</sourceDirectory>
        <scriptSourceDirectory>${basedir}/src</scriptSourceDirectory>
        <testSourceDirectory>${basedir}/src</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

With this file I would like to have the following structure:

├── pom.xml
└── src
    └── ClassTest.java

Instead of the default structure on https://github.com/jottinger/owlapi-tutorial:

├── pom.xml
└── src
    └── test
        └── java
            └── com
                └── autumncode
                    └── owlapi
                        └── ontology
                            └── ClassTest.java

However after I change the pom.xml file above using http://maven.apache.org/pom.html#Build_Element, it gives the error:

$ mvn test -e -X
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T16:39:06-03:00)
Maven home: D:\User\Documents\apache_marven\maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_65\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "x86", family: "windows"
...
[INFO] 5 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.184 s
[INFO] Finished at: 2017-05-13T21:57:39-03:00
[INFO] Final Memory: 16M/40M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project TestJava: Compilation failure: Compilation failure: 
[ERROR] /D:/owlapi/src/ClassTest.java:[2,18] package org.testng does not exist
[ERROR] /D:/owlapi/src/ClassTest.java:[3,30] package org.testng.annotations does not exist
[ERROR] /D:/owlapi/src/ClassTest.java:[5,25] package org.testng does not exist
[ERROR] /D:/owlapi/src/ClassTest.java:[9,10] cannot find symbol
[ERROR]   symbol:   class Test
[ERROR]   location: class ClassTest
[ERROR] /D:/owlapi/src/ClassTest.java:[12,9] cannot find symbol
[ERROR]   symbol:   method assertTrue(boolean)
[ERROR]   location: class ClassTest
[ERROR] -> [Help 1]

For the following source code within the file src/ClassTest.java:

import org.testng.Assert;
import org.testng.annotations.Test;

import static org.testng.Assert.*;

public class ClassTest
{
    @Test
    public void testAddClassesSimple() 
    {
        assertTrue( true );
    }
}

I removed the OWL imports from the code above for simplicity, as the problems seems to be only with testng framework.

What is wrong with the pom.xml above to it not work with testng anymore while having the following structure for my source files:

├── pom.xml
└── src
    └── ClassTest.java
Evandro Coan
  • 8,560
  • 11
  • 83
  • 144
  • 1
    Possible duplicate of [Maven Compilation error \[package org.testng.annotations does not exist\]](http://stackoverflow.com/questions/20345451/maven-compilation-error-package-org-testng-annotations-does-not-exist) – Evandro Coan May 14 '17 at 01:15
  • I changed the `test` to `compile` and it worked with the full OWL file. – Evandro Coan May 14 '17 at 01:21

0 Answers0