Nexus 3 Site Deployment - java

I have a project which was deploying a maven-generated site to a nexus2 repository. Here's my current configuration:
<distributionManagement>
<repository>
<id>nexus-group</id>
<url>http://[some_url]/repository/[repo]-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-group</id>
<name>Internal Snapshots</name>
<url>http://[some_url]/repository/[repo]-snapshots/</url>
</snapshotRepository>
<site>
<id>nexus-group</id>
<url>dav:http://[some_url]/repository/[repo]-site/[project]/latest/</url>
</site>
</distributionManagement>
I have recently updated to nexus3 and created a raw repository for deployment, but have encountered some issues.
It seems when creating Javadocs, a javascript file (script.js) is created in the /target/site/apidocs directory. Why am I unable to upload this file into a raw repository? This fails the build.
For every file which is uploaded I have a transfer error (even on the initial upload): java.io.IOException: unable to create collection: http://[some_url]/repository, status code = 400. Is this my error or Nexus'? Ultimately the upload is successful along with the build, assuming script.js isn't present.
In nexus2 content was conveniently grouped by artifactId which could be drilled-down to using the UI browser. Am I deploying incorrectly or is this feature no longer available? I haven't found anything to tell me otherwise.
Thanks in advance.

Have you added correctly webdav-jackrabit to your maven-site-plugin configuration:
<build>
<plugins>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.6</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Related

How to add android library Volley to a plain maven project

I would like to try the Volley library on my plain maven project with java 8 or 11. I am however not able to add this dependency properly. It is an android library by google. So I am not using android studio, but just Intellij IDEA with maven.
When I add it as:
<dependency>
<groupId>com.android.volley</groupId>
<artifactId>volley</artifactId>
<version>1.1.1</version>
</dependency>
I am getting: Cannot resolve com.android.volley:volley:1.1.1
When I include the type pom as instructed here: https://bintray.com/android/android-utils/com.android.volley.volley/1.1.1#
<dependency>
<groupId>com.android.volley</groupId>
<artifactId>volley</artifactId>
<version>1.1.1</version>
<type>pom</type>
</dependency>
I am not getting errors, but I cannot use the java class from my java source.
I also included the following plugin
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.6.0</version>
<extensions>true</extensions>
</plugin>
I know that this library is not available at maven central, so I added jcenter as additional repository:
<repository>
<id>bintray-central</id>
<name>Bintray Central Repository</name>
<url>https://jcenter.bintray.com</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
Any idea if it would be possible what I am trying to do?

How to upload maven plugin to Github packages?

Consider I have a maven plugin project and I want to publish it to Github's public maven repository called "Github Packages". I've done everything by instruction and for normal projects everything works fine out of the box. But for maven plugin projects with packaging=maven-plugin the instruction doesn't work.
In build log I see something like this:
[WARNING] Could not transfer metadata repo-name/maven-metadata.xml
from/to github (https://maven.pkg.github.com/user-name/repo-name):
Failed to transfer file:
https://maven.pkg.github.com/user-name/repo-name/group-id/maven-metadata.xml.
Return code is: 422 , ReasonPhrase:Unprocessable Entity.
It seems the maven deploy plugin needs maven-metadata.xml in the group-id's root, but can't find it and no one puts it there. How to solve this problem?
I use Apache Maven 3.3.9, and use the command:
mvn clean deploy
--Addition: example of pom file I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub my_repo Apache Maven Packages</name>
<url>https://maven.pkg.github.com/my_nick/my_repo</url>
</repository>
</repositories>
<version>1.0.0</version>
<groupId>x</groupId>
<artifactId>some-plugin</artifactId>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>x</groupId>
<artifactId>my-dependency</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.15.12</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
</plugins>
</build>
</project>
Unfortunately I haven't found the right answer to my question, it seems that for now it's impossible to add Maven plugins to Github Packages.
However I found a workaround which uses S3 as a repository backend, so you don't need heavyweight solutions like Nexus or JFrog. You can read this and this on how to do it.
I had the same problem 422 from server: Unprocessable Entity when publishing Maven artifacts from GitHub Actions to GitHub Packages. The reason was that the corresponding tag for the uploaded artifact didn't exist yet.
The error message may be better in this case.
If you have already uploaded the artifact to the GitHub Packages then it means you have configured everything right.
I suppose the real reason for the 422 error is that you are trying to upload the same artifact with the same version that already was uploaded. And if it is not a SNAPSHOT version then the repository should deny replacing it so it behaves correctly.
I got the same error when trying to redeploy the already deployed package:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project MavenPluginForGithub:
Failed to deploy artifacts: Could not transfer artifact ru.dmochalov:SampleMavenPluginForGithub:jar:1.0.3 from/to github (https://maven.pkg.github.com/dmochalov/hello-world):
Failed to transfer file: https://maven.pkg.github.com/dmochalov/hello-world/ru/dmochalov/SampleMavenPluginForGithub/1.0.3/SampleMavenPluginForGithub-1.0.3.jar.
Return code is: 422, ReasonPhrase: Unprocessable Entity. -> [Help 1]
How to fix?
Is suppose you have two options:
Increment the version <version>1.0.0</version> of the plugin from 1.0.0 to 1.0.1. Consider using 1.0.1-SNAPSHOT versions if the plugin is unstable and under development. GitHub allows redeploying artifacts with SNAPSHOT versions. So you could always redeploy it when developing.
Delete the package from the repo. You can do it only for packages in a private repository.
422 error vs 401 error
I suppose that there is not accepted specification or standardization for error codes and different repositories behave differently. For example, the Maven Central repository replies with 401 error when attempting to replace the already deployed version.
Why GitHub decided to use 422 is a mystery. There is an answer in the community forum but without proper explanation.
Here's the official github link for how to do exactly that. However, since this doesn't seem to be of much help, here's a link to a gradle forum question that should help you with this. Best of luck!

Maven can't resolve the Kotlin Maven Plugin jar

Not sure how to fix this.
I want this version of the Kotlin runtime and maven plugin.
These are the bits in my pom.xml:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-runtime</artifactId>
<version>1.2-M2</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>1.2-M2</version>
<executions>
And I added this as a repo:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>kotlin-bintray</id>
<name>Kotlin Bintray</name>
<url>http://dl.bintray.com/kotlin/kotlin-dev/</url>
</repository>
I get this error:
Failure to find
org.jetbrains.kotlin:kotlin-maven-plugin:jar:1.2-M2 in
https://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are
forced
But I don't see anything that might be wrong.
By the way, notice that the runtime jar is found, so the repository section must be correct since this repository is where maven finds it. The maven plugin jar is a different matter for some reason though...
I just fixed. It was something really silly. I found out that for plugins one needs to define a plugin repository section.
<pluginRepositories>
<pluginRepository>
<id>kotlin-bintray</id>
<name>Kotlin Bintray</name>
<url>http://dl.bintray.com/kotlin/kotlin-dev</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
And now it works. I guess I should spend more time learning maven in depth :)
To make sure it downloads fresh from maven central you will need to blow away your local copy, so delete the directory:
~/.m2/repo/org/jetbrains/kotlin/kotlin-maven-plugin
You will also need to add the 3rd party repo to your settings.xml at ~/.m2 see here
<settings>
...
<profiles>
...
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>https://dl.bintray.com/kotlin/kotlin-dev/</url>
</repository>
</repositories>
</profile>
...
</profiles>
<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>
...
</settings>
At the documentation, we can see how to implement Compiler Plugins
For kotlin-allopen add the followin <configuration> and <pluginOptions> inside the <plugin> tag
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<!-- Or "spring" for the Spring support -->
<plugin>all-open</plugin>
</compilerPlugins>
<pluginOptions>
<!-- Each annotation is placed on its own line -->
<option>all-open:annotation=com.my.Annotation</option>
<option>all-open:annotation=com.their.AnotherAnnotation</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
i just added this line and it worked for me
<version>${kotlin.version}</version>

IDEA Groovy test class already exists

IDEA is giving my groovy class the warning `class "MyClassTest" already exists in "my.class.package". It also doesn't seem to be doing a very good job of keeping the class updated when I run the test. I'll add an assertion guaranteed to fail, or succeed and it won't recognize it until later (later so far seems arbitrary). Given that I have maven tests passing and running correctly I suspect this is simply an IDEA configuration problem
here's my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xenoterracide</groupId>
<artifactId>rpf</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.9.RELEASE</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>testGenerateStubs</goal>
<goal>testCompile</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
<configuration>
<testSources>
<testSource>
<directory>${project.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.8.0.DATAJPA-622-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1102-jdbc41</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.3.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<!-- use UTF-8 for everything -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<start-class>com.xenoterracide.rpf.Application</start-class>
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<url>http://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>http://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
I've fixed the issue by marking the target folder of the artifact as "Excluded".
I think the duplication is caused by the stub files generated in target/generated-sources/groovy-stubs. IDEA must be too curious about these files and might add them to the source set.
I had the exact same problem and setting target dir as excluded didn't help either. I noticed that the directory:
/target/generated-sources/groovy-stubs/test
was getting set as a Sources Root in IDEA. I'd uncheck that in the UI and the error would go away, but as soon as I'd rebuild project it was back to it again. Very frustrating. Until I started looking at all the gmavenplus-plugin execution goals.
It turned out I had a few too many goals listed. If you're only using groovy for testing purposes, like I am (with Spock - I'm so done with JUnit), you should only have the following goals enabled under that plugin:
addTestSources
testGenerateStubs
testCompile
removeTestStubs
Remove the rest of them. Once you do that IDEA should be all good with your groovy tests (or Specs in my case). Let me know if that really helped.
This is because of IntelliJ knows groovy by nature, the only thing you have to do is DO NOT activate gmaveplus-plugin in IntelliJ:
<profiles>
<profile>
<id>groovy-integration</id>
<!-- profile to incorporate gmaveplus in normal build -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>testGenerateStubs</goal>
<goal>testCompile</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>development-in-idea</id>
<!-- suppress `groovy-integration` profile by default in IntelliJ -->
<activation>
<property>
<name>idea.version</name>
</property>
</activation>
</profile>
</profiles>
One down side is that when you run maven goal from IntelliJ IDEA's Maven Projects tool window directly, the groovy-integration profile will not be activated as usual.
However, you can always navigate to the test folder, click "Run 'Tests in '...''" and have all the benefits brought to you by IntelliJ.
Exclude gmavenplus-plugin within IntelliJ IDEA takes one more advantage, IntelliJ IDEA sometimes add the generated test stubs as Sources instead of Test Sources, and unable to compile them due to lack of test-scoped dependencies.
I too get the message saying that my groovy class already exists. What I discovered is that it occurs after I Make Project the first time. From then on that error always occurs. If you want to get rid of the error, all you have to do is to delete the jar file produced stored in the app/build/libs directory. And of course, if you re Make Project again, the error comes back. So it's kind of tripping over itself by including it's own output jar lib in detecting that error.
I think its just a nuisance error and it doesn't seem to mess things up. It's certainly annoying to get an error indication when you don't have anything wrong. Perhaps there's someway to prevent this bogus error with some kind of groovy lint option, etc.; I just don't know. I would think that Michel solution of excluding certain files like the output lib file would work. The lack of good, reliable and consistent documentation concerning groovy and gradle builds makes me not interested in wanting to solve this problem; especially since it appears to just be a nuisance error.
Here's a little update. I did solve the problem, but I'm not exactly sure what the exact sequence you need to do to solve it. The best I can do is to explain the things that I dinked with. My solution seems to be centered around the solution posted at "Class already exists" error in IntelliJ on Groovy class . They talk about excluding a file from IntelliJ. I'm using Android Studio 3.1.3 and I couldn't exactly find a way to do what they where saying in that post. If I went into the Project tab and seletected Project Files I was able to navigate to my build folder. That directory was already marked as excluded. I did toggle it to being included and then back to being excluded. That did not seem to fix the problem. I then noticed that one could also load/unload modules. If I unloaded in my case the 'app' module and clicked okay, the error about the class already existing went always. However, the class file still thought their was an error. In other words, the class file name in the tab still had a squiggle line underneath it's name. Note however, there were no lines in error in the actually class file. I then played around with various attempts of unloading and loading of Modules executing them positioned at various other places in the directory file structure and cleaning the project. At the end, I just left things in the state where every module was loaded. I then closed the Android Studio project and reopened it. What I noticed was that the in Project Files tab, I could no longer see or navigate to the build directory as I previously could. And more importantly, the error about the class already existing went away. So something in the sequence of things I dinked with fixed the problem, but it didn't take affect until I closed Android Studio and restarted it. I've noticed in other situations where Android Studio need to be close and restarted to actually correct itself.

Qt Jambi Javadoc missing

When i fetched qt jambi jars from maven repository i found that there is no javadocs in it.
Downloading javadocs in maven didn't help.
My pom.xml:
<dependencies>
<dependency>
<groupId>net.sf.qtjambi</groupId>
<artifactId>qtjambi</artifactId>
<version>4.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.sf.qtjambi</groupId>
<artifactId>qtjambi-maven-plugin</artifactId>
<configuration>
<!-- Specifies where sources are. This parameter is MANDATORY -->
<sourcesDir>src/main/java</sourcesDir>
<!-- following parameters aren't mandatory, they use defaults as specified
here if not specified <translationsDir>src/main/resources/translations</translationsDir>
<destinationDir>target/generated-sources/qtjambi</destinationDir> -->
<!-- cause -noobsolete switch for lupdate -->
<noObsoleteTranslations>true</noObsoleteTranslations>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>qtjambi</id>
<name>qtjambi</name>
<url>http://qtjambi.sourceforge.net/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>qtjambi</id>
<name>qtjambi</name>
<url>http://qtjambi.sourceforge.net/maven2/</url>
</pluginRepository>
</pluginRepositories>
I've tried to download jar manually, but there is still no javadoc in it.
http://repository.qt-jambi.org/nexus/content/repositories/releases-before-2011/net/sf/qtjambi/qtjambi-maven-plugin/4.6.3.1/ should contains qtjambi-maven-plugin-4.6.3.1-javadoc.jar. It's not there, so file a request at that project that they upload there javadocs as well.

Categories

Resources