intellij idea - Maven project dependency "could not find artifact" -
i have 2 maven projects. project , project b. project b dependent on project not other way around.
in project b pom have this:
<dependency> <groupid>com</groupid> <artifactid>projecta</artifactid> <type>pom</type> <version>1.0-snapshot</version> </dependency> when try package project fails error:
[error] failed execute goal on project projectb: not resolve dependencies project com:projectb:war:1.0-snapshot: not find artifact com:projecta:pom:1.0-snapshot -> [help 1] org.apache.maven.lifecycle.lifecycleexecutionexception: failed execute goal on project projectb: not resolve dependencies project com:projectb:war:1.0-snapshot: not find artifact com:projecta:pom:1.0-snapshot so can't find projecta pom. need put in project? should located in file structure.
for it's worth, using intellij ide.
thanks in advance.
edit: when run install on projecta error:
the packaging project did not assign file 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>
you have install projecta in local maven repo (or otherwise make available in whatever remote repositories pom.xml or settings.xml point at). example:
cd whereever/projecta/lives mvn clean install this write com/projecta/projecta.pom local maven repo , when ...
cd wherever/projectb/lives mvn clean install ... maven resolve projecta.pom location.
note: dependency have declared on projecta:
<dependency> <groupid>com</groupid> <artifactid>projecta</artifactid> <type>pom</type> <version>1.0-snapshot</version> </dependency> ... transitively add dependencies declared in com:projecta projectb's pom, intention? makes sense if projecta packaged pom, if packaged jar need update dependency declaration in projectb remove line: <type>pom</type>.
Comments
Post a Comment