Cannot resolve maven dependency - maven

I have written a custom plugin and I deploy it to an internal company repository. I have another project that uses the plugin (here is the pom.xml snippet):
<build>
<plugins>
<plugin>
<groupId>com.mycompany.mypackage</groupId>
<artifactId>json-schema-generator-main</artifactId>
<version>1.0.0-SNAPSHOT</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>json-schema-generator-main</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I deploy my custom plugin to our internal repo and my local one successfully. If I remove it from my local repo, however, when I run "mvn clean install" in the dependent project I get the following output:
[ERROR] Plugin com.mycompan.mypackage:json-schema-generator-main:1.0.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact com.mycompany.mypackage:json-schema-generator-main:jar:1.0.0-SNAPSHOT ->
What could be causing this behavior? I'm happy to provide more information, such as the details of my custom plugin, which uses a lot of reflection and classpath hackery to generate Json Schema text files, or it's pom.xml, but I'm not sure what would be relevant without turning this into a wall of text. As best I can tell it is correctly deployed in the repo, and this problem only occurs if you remove the custom plugin from your local repository.

Answered in comments:
I had a versioning issue in my deployment to the internal repository.
The files were not being properly named and therefore obviously could
not be found. I apologize. – Jesse Aug 14 '14 at 19:12

Related

Setup Intellij to hot update jars and run Maven Appassembler

I want to setup Intellij to automatically do what I am doing from the command-line with maven repeatedly, which is to run mvn package -DskipTests to rebuild my jar and run the Appassembler Maven plugin to produce my runnable scripts. Ideally, all I want it to do is hot update the classes within the jar which I have changed.
I have figured out how to tell Intellij to create jars with the Artifact tab in Project Structure, but can I get Intellij to import this artifact information from the pom instead of me setting it up manually?
It does auto-import pom changes, but never imported this artifact info.
This would enable it to use the exact output name of what maven produces, so that whether I'm working from the command-line or IDE I can work with one set of outputs. (reason below)
Appassembler adds an additional step, which includes it copying all the dependencies into its target folder and producing the scripts. If Intellij can't trigger Appassembler, I was thinking maybe Appassembler could use symlinks instead and the when the jar as updated, my runnable app scripts would immediately be using that version. Or in the worse case, I only need to run this particular step from the command-line, the jar having already been built.
Update
In case it helps, here's how I use Appassembler in my pom.xml:
<build>
<plugins>
<plugin>
<executions>
<execution>
<id>package</id>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<programs>
<program>
<mainClass>com.foo.bar.Foobnobicator</mainClass>
<name>gofoo</name>
</program>
</programs>
</configuration>
</plugin>
</plugins>
</build>
Thanks for the advice on the best way to achieve this.

Deploying maven project to nexus server using git-describe plugin output

I have several maven projects that deploy to a nexus server. I don't like managing their versions via the pom file, and already use git tags for versioning via git-describe.
I added the git-describe maven plugin with the following config:
<plugin>
<groupId>com.lukegb.mojo</groupId>
<artifactId>gitdescribe-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<goals>
<goal>gitdescribe</goal>
</goals>
<id>git-describe</id>
<phase>initialize</phase>
<configuration>
<outputPrefix></outputPrefix>
</configuration>
</execution>
</executions>
</plugin>
and it works perfectly for mvn package runs - but when I use mvn deploy I end up seeing:
nexus/content/repositories/releases/me/botsko/project/${describe}/project-${describe}.jar
I tried to talk to the plugin author but it's been a few days and no reply.
How can I modify the plugin, or my configuration to property set the version during the deploy phase?
There may be a way to edit the plugin but I'm not familiar with how the maven plugin architecture works.
I solved the problem by writing a shell script that passes the same git-describe value to the maven deploy process:
#!/bin/sh
gitvers=`git describe`
mvn deploy -Ddescribe=$gitvers-SNAPSHOT
Just make sure you use <version>${describe}</version> or similar in the POM.

Maven release plugin: How to deploy only a distribution jar on release:perform

I have a multimodule project, and the last module being built is a distribution zip of the application.
core/
plugins/
plugins/logger
plugins/social
...
assemble/
I want to distribute the application in the form of Maven artifact. And I don't want to deploy the modules artifacts with it.
But the release plugin needs to run from the root (I want to do all the usual stuff like updating versions, tagging, commits these changes etc.)
What is the way to tell the release plugin which artifacts to deploy?
Note that this is different from limiting only the deploy plugin, because release plugin seems to call the deploy plugin in certain internal way. (Not sure about that.)
Seems like the Release plugin behavior was fixed and it now properly invokes deploy:deploy.
So I used my standard trick to suppress default plugin execution. Root pom.xml:
<!-- Don't deploy all artifacts. Overridden in submodules. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions> <execution> <id>default-deploy</id> <phase>none</phase> </execution></executions>
</plugin>
And the dist module pom.xml:
<!-- Enable deploy for this submodule. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions> <execution> <id>default-deploy</id> <phase>deploy</phase> </execution></executions>
</plugin>
The release:perform isn't doing that much magic. It checks out the code by the tag which was created during release:prepare. The default goal is 'deploy'. If you have specified a site within the distributionManagement of the pom.xml it'll be 'deploy site-deploy'. These steps could also be done by hand.
If you never want to deploy these artifacts (not during developerment nor release), I'd prefer the skip over using an undefined phase.
If this is only required during a release, you should specify this within a release-profile.

Xcode Maven Plugin : adding extra headers

The Xcode Maven Plugin from http://sap-production.github.io/xcode-maven-plugin/site is a nice maven plugin for people who like maven and wan't to avoid some pain with xcode dependencies, framework creation and such.
It creates and installs lib and headers in the repository.
The headers are bundled in a .tar file during the process.
For some reason, I need to edit the tar file and add a few files in it before installing.
But as I'm quite the noob regarding maven, I need some help !
How can I modify on a byproduct of Maven before it is installed ? I suppose I can write some script that add some files to the .taf, but how can I be sure it's executed prior the installation ?
#Redwarp - It's been a while since this question was asked, but I'll offer up an answer.
You can configure a Maven plug-in's goal to be executed during a particular phase in the Maven build lifecycle.
Pick a phase that's executed before the install phase. Package may be the best phase for you to edit your tar file and add your required files.
The following is just a generalized example (the focus should be on phase and goal):
<project>
...
<build>
<plugins>
<plugin>
<groupId>com.sap.prd.mobile.ios.mios</groupId>
<artifactId>xcode-maven-plugin</artifactId>
<version>1.12.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>do-something</id>
<phase>package</phase>
<configuration>
...
</configuration>
<goals>
<goal>plugin-goal</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
Find the plug-ins that suit your needs and bind their goals to the appropriate Maven lifecycle phases...which there's a good chance that you have already figured out by this point.

Maven Artifact download?

I'm new to maven world. My organization has maven release process all the artifacts are kept in our maven remote repo, so I want to deliver some specific artifact version to some of our customer. How can I download specific module version?
In case you don't have a web interface like Nexus for your internal repo, you can create a standalone pom.xml, enter the desired version into the dependencies and call mvn package.
If you need some sample poms and extra info to get you started, you can look here and here
EDIT : I forgot you might expect the artifact to turn up in the same folder as the pom is in. The default maven setting is to download it to a subfolder of /yourHomeFolder/.m2/repository/The name of the subfolder is the group Id of the artifact.
EDIT2: here is a sample setup for downloading the jars into the folder of your choice. If you delete the <outpuDirectory> setting, the artifact jar will be downloaded into the subfolder /dependendies. The execution is bound to the validate phase, so just call mvn validate
<build>
...
<plugins>
<!-- Dependency plugin to download the configured dependencies (transitive). -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<execution>
<execution>
<id>download-jar</id>
<phase>validate</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>put/your/directory/here</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

Resources