7

I'm trying to deploy a maven project to a remote repository.

mvn install works just fine for local repository.

I'm using Groovy and the Groovy-Eclipse compiler plugin. I tried to run mvn deploy to deploy to a remote repository and I got the following error:

The packaging for this project did not assign a file to the build artifact -> [Help 1]

This is my pom.xml:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.github.notacariocafacil</groupId>
    <artifactId>notacariocafacil</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>1.8.6</version>
        </dependency>
    </dependencies>

    <build>
        <extensions>
            <extension>
                <groupId>org.kuali.maven.wagons</groupId>
                <artifactId>maven-s3-wagon</artifactId>
                <version>1.2.1</version>
            </extension>
        </extensions>
        <plugins>
          <plugin>
             <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                   <compilerId>groovy-eclipse-compiler</compilerId>
                   <source>1.6</source>
                    <target>1.6</target>
                </configuration>
                <dependencies>
                    <dependency>
                       <groupId>org.codehaus.groovy</groupId>
                       <artifactId>groovy-eclipse-batch</artifactId>
                       <version>1.8.6-01</version>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                       <artifactId>groovy-eclipse-compiler</artifactId>
                        <version>2.7.0-01</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-eclipse-compiler</artifactId>
                <version>2.7.0-01</version>
                <extensions>true</extensions>
             </plugin>
        </plugins>
    </build>
</project>

Do I need to add something in the build step?

Bianca Rosa
  • 197
  • 1
  • 3
  • 10
  • Did you run `mvn deploy` or mvn `deploy:deploy`? – Stefan Ferstl Nov 26 '15 at 20:33
  • 1
    Possible duplicate of [Maven: The packaging for this project did not assign a file to the build artifact](http://stackoverflow.com/questions/6308162/maven-the-packaging-for-this-project-did-not-assign-a-file-to-the-build-artifac) – A_Di-Matteo Jul 01 '16 at 12:34

3 Answers3

14

You need to run mvn deploy instead of mvn deploy:deploy. The former executes the maven lifecycle up to the "deploy" phase, i.e. it compiles your code, packages it into a JAR file and finally deploys it to your remote repository.

mvn deploy:deploy on the other hand does only execute the deploy goal of the maven-deploy-plugin. Without the context of the previously executed lifecycle phases, which produce your actual build artifact (the JAR file), the maven-deploy-plugin does not have anything to deploy and aborts with the error The packaging for this project did not assign a file to the build artifact. This behavior is also explained in the FAQ of the maven-deploy-plugin.

Stefan Ferstl
  • 5,135
  • 3
  • 33
  • 41
0

CAREFUL. This apparently can also happen if you have your projects being built by maven, in a folder that has a bad naming convention. I just realized this after troubleshooting this error for 3 days, that my folder was named {migration repos} it literally created a jacked up file called "migration" and broke the maven install.

William Tolliver
  • 305
  • 1
  • 2
  • 16
-1

for the new Maven 3.8.x, try removing the "package" from the command.

Bishoy Hanna
  • 4,539
  • 1
  • 29
  • 31
  • 1
    This has nothing to do with packaging or with Maven 3.8.x. The maven install and maven deploy plugin since version 3.0.0 require your project to have a main artifact if your project has `jar`. So if you have e.g. only tests in a project, this error will come up as well. Check if your project has the correct packaging, e.g. packaging pom if you only have a pom file. If you can't change the packaging, then as an ugly workaround you could add a dummy class in `src/main/java`. This will be compiled and deployed in the regular jar. – Joep Weijers Feb 20 '23 at 07:21
  • im leaving this answer here for whom they face the same error like me even if its different cause – Bishoy Hanna Feb 20 '23 at 22:13
  • Thanks @JoepWeijers. I faced same issue (project with no class in `main/java` but only in `test/java`). Create a dummy class in `main/java` did the trick. – Camille Sep 01 '23 at 07:51