1

I have project with few modules. One of them is "core" which compiles into jar and I'm using it as dependency for all other modules.
pom.xml for "core" module:

<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">
    <parent>
        <artifactId>my-project</artifactId>
        <groupId>com.myproject</groupId>
        <version>1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <version>1.0</version>
    <artifactId>my-core-project</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

pom.xml for app module

<?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">
  <parent>
    <artifactId>my-project</artifactId>
    <groupId>com.myproject</groupId>
    <version>1.0</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <packaging>war</packaging>

  <artifactId>my-project-app</artifactId>
  <version>1.0</version>

  <dependencies>
      <!-- ... -->
      <dependency>
          <groupId>com.myproject</groupId>
          <artifactId>my-core-project</artifactId>
          <version>1.0</version>
      </dependency>
  </dependencies>
</project>

Second module is App Engine module. So I can run in console mvn install for my core module and than run mvn appengine:devserver for app module and it will work. But I want to run app module from IDE. I have installed App Engine plugin for Intelij, and add configuration to run my app module, but the problem is that run fails with error

Error:(10, 15) java: package org.junit does not exist

Tests are inside core project, and structure of core module is like this

.
├── my-core-project.iml
├── pom.xml
├── src
│   ├── main
│   │   ├── java
│   │   └── resources
│   └── test
│       ├── java
│       └── resources

How can I run app module from IDE?

cooperok
  • 4,249
  • 3
  • 30
  • 48
  • This looks like two separate problems to me. If you want to run the appengine artifact from intellij you should remove the installed dependencies from your local repository since IntelliJ will build the artifact with local dependencies for you. `mvn dependency:purge-local-repository` would be your helper with that. Package org.junit should be marked `test` in your poms. Once you verified all that you should do a maven reimport on your modules in IntelliJ. – konqi May 04 '16 at 10:39
  • Unfortunatelly purge doesn't help me. And junit dependency already has scope test. – cooperok May 04 '16 at 10:58
  • Interesting, it's what made it work for me. I use an external installation of maven though. You could try and rename your local repository, respectively simulate a delete and do a mvn clean for all your artifacts. Another possibility is that your core module is not a snapshot. I recommend you use a snapshot version during development (see http://stackoverflow.com/questions/5901378/what-exactly-is-a-maven-snapshot-and-why-do-we-need-it for why). – konqi May 04 '16 at 11:09
  • There is option in IDE console if click on error 'Exclude from compile', so I clicked on it. After that IDE don't check that files while I am running modules – cooperok May 04 '16 at 13:26

0 Answers0