Maven project dependency "could not find artifact"

Viewed 23697

I have 2 maven projects. Project A and Project B. Project B is dependent on Project A but not the other way around.

In my project B pom I have this:

    <dependency>
        <groupId>com</groupId>
        <artifactId>ProjectA</artifactId>
        <type>pom</type>
        <version>1.0-SNAPSHOT</version>
    </dependency>

When i try to package the project it fails with this error:

 [ERROR] Failed to execute goal on project ProjectB: Could not resolve    dependencies for project com:ProjectB:war:1.0-SNAPSHOT: Could not find  artifact com:ProjectA:pom:1.0-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project ProjectB: Could not resolve dependencies for project com:ProjectB:war:1.0-SNAPSHOT: Could not find artifact com:ProjectA:pom:1.0-SNAPSHOT

So it can't find my ProjectA pom. Do I need to put it in my project? Where should it be located in my file structure.

For what it's worth, I am using intelliJ IDE.

Thanks in advance.

EDIT: When i run install on projectA I get this error:

The packaging for this project did not assign a file to the build artifact

EDIT2 - Adding ProjectA pom:

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu</groupId>
<artifactId>ProjectA</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>ProjectA</name>

<build>
    <sourceDirectory>src/main/java</sourceDirectory>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.5.2</version>
            <executions>
                <execution>
                    <id>install-jar-lib</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <id>prepare-package</id>
                    <phase>prepare-package</phase>
                    <configuration>
                        <target>
                            <copy file="${basedir}/src/main/webapp/META-INF/context-${app.environment}.xml"
                                  tofile="${basedir}/src/main/webapp/META-INF/context.xml" />
                            <copy file="${basedir}/src/main/webapp/WEB-INF/web-${app.environment}.xml"
                                  tofile="${basedir}/src/main/webapp/WEB-INF/web.xml" />
                            <copy file="${basedir}/src/main/resources/log4j-${app.environment}.xml"
                                  tofile="${basedir}/src/main/resources/log4j.xml" />
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
                <execution>
                    <phase>compile</phase>
                    <configuration>
                        <target>
                            <copy file="${project.build.directory}/classes/log4j-${app.environment}.xml"
                                  tofile="${project.build.directory}/classes/log4j.xml" />
                            <delete>
                                <fileset dir="${project.build.directory}/classes" includes="**/*-local.*"/>
                                <fileset dir="${project.build.directory}/classes" includes="**/*-test.*"/>
                                <fileset dir="${project.build.directory}/classes" includes="**/*-prod.*"/>
                            </delete>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
                <execution>
                    <id>package</id>
                    <phase>package</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target>
                            <delete file="${basedir}/src/main/webapp/META-INF/context.xml" />
                            <delete file="${basedir}/src/main/webapp/WEB-INF/web.xml" />
                            <tstamp>
                                <format property="last.timestamp" pattern="yyyyMMddHHmmss"/>
                            </tstamp>
                            <property name="build.time" value="${last.timestamp}" />
                        </target>
                        <exportAntProperties>true</exportAntProperties>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <failOnMissingWebXml>true</failOnMissingWebXml>
                <!--<webResources>
                    <resource>
                        <directory>src/main/WEB-INF/lib</directory>
                        <targetPath>WEB-INF/lib</targetPath>
                        <filtering>false</filtering>
                        <includes>
                            <include>**/*.jar</include>
                        </includes>
                    </resource>
                </webResources>-->
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.coderplus.maven.plugins</groupId>
            <artifactId>copy-rename-maven-plugin</artifactId>
            <version>1.0.1</version>
            <executions>
                <execution>
                    <id>rename-file</id>
                    <phase>package</phase>
                    <goals>
                        <goal>rename</goal>
                    </goals>
                    <configuration>
                        <sourceFile>${project.build.directory}/${artifactId}-${version}.war</sourceFile>
                        <destinationFile>${project.build.directory}/ProjectA##${build.time}.war</destinationFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

1 Answers
Related