0

[ERROR] Failed to execute goal on project portal: Could not resolve dependencies for project com.learning:portal:war:1.0.0-SNAPSHOT: Could not find artifact com.myapp.Local-2017:jar:1.0 in central (https://repo.maven.apache.org/maven2)

In pom.xml:

<dependency>
    <groupId>com.myapp.Local</groupId>
    <artifactId>Local-2017</artifactId>
    <version>1.0</version>
</dependency>

Plugins:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.5</version>
    <executions>
        <execution>
            <phase>clean</phase>
                <configuration>
            <repositoryLayout>default</repositoryLayout>
                <groupId>com.myapp.Local</groupId>
                <artifactId>Local-2017</artifactId>
                <version>1.0</version>
                <packaging>jar</packaging>
                <file>${basedir}/lib/Local.jar</file>
                <generatePom>true</generatePom>
            </configuration>
            <goals>
                <goal>install-file</goal>
            </goals>
        </execution>
    </executions>
</plugin>
dferenc
  • 7,918
  • 12
  • 41
  • 49

2 Answers2

1

You declared a Maven dependency

<dependency>
  <groupId>com.myapp.Local</groupId>
  <artifactId>Local-2017</artifactId>
  <version>1.0</version>
</dependency>

If Maven does not find it in your local repository, it will try to download it from outside. If you do not have a settings.xml it will try MavenCentral.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
0

I suspect that part of the problem is that you have put the execution of "maven-install-plugin" into the "clean" phase. According to the Maven 3.5 Documentation, the "clean" phase is part of the "clean" life-cycle; i.e. gets run when you run "mvn clean".

I think it should be in the "default" lifecycle, probably the "validate" or "initialize" phase. Note that dependency resolution typically occurs in a later phase. It happens in the first phase that uses a plugin that requires dependency resolution as a prerequisite. Put the "install-file" goal into an earlier phase in the lifecycle.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216