Can not build standart example "NetBeans Platform Quick Start Using Maven" - maven

I tried to perform muti-module example for integration maven and netbeans (https://platform.netbeans.org/tutorials/nbm-maven-quickstart.html) step by step. When I finished coding I have known that it's necessary to add libs org.openide.util and org.openide.util.lookup in my maven app. So I can't find the way to do this.
I find some repos which contains this libs:
oss.sonatype.org/content/repositories/releases/com/googlecode/sarasvati/thirdparty/netbeans/org-openide-util/7.3/ and
repo1.maven.org/maven2/com/googlecode/sarasvati/thirdparty/netbeans/ )
But when I trying to add this repo in netbeans it refuse to index it.
Then I'm trying to add repo in pom.xml. In TextFilter module I'm add:
... <modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>org_openide_util_repo</id>
<url>https://repository.sonatype.org/service/local/repositories/atlassian/content/org/codeartisans/thirdparties/swing/org-openide-util/8.6.2/</url>
</repository>
</repositories>
...
<dependency>
<groupId>org.codeartisans.thirdparties.swing</groupId>
<artifactId>org-openide-util</artifactId>
<version>8.6.2</version>
</dependency>
<dependency>
<groupId>org.codeartisans.thirdparties.swing</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<version>8.3.1</version>
</dependency> ...
But when I trying "build with dependencies" MavenPlatformWordApp, I get mistake:
Failed to execute goal
org.codehaus.mojo:nbm-maven-plugin:3.13:cluster-app
(default-cluster-app) on project MavenPlatformWordApp-app: Failed to
retrieve the nbm file from repository: Could not find artifact
org.codeartisans.thirdparties.swing:org-openide-util:nbm:8.6.2 in
netbeans (bits.netbeans.org/nexus/content/groups/netbeans/)
I'm tryed to add reference to repo in pom.xml MavenPlatformWordApp, them mistake takes the form:
Failed to execute goal
org.codehaus.mojo:nbm-maven-plugin:3.13:cluster-app
(default-cluster-app) on project MavenPlatformWordApp-app: Failed to
retrieve the nbm file from repository: Could not find artifact
org.codeartisans.thirdparties.swing:org-openide-util:nbm:8.6.2 in
org_openide_util_repo
(repository.sonatype.org/service/local/repositories/atlassian/content/org/codeartisans/thirdparties/swing/org-openide-util/8.6.2/)
Google search is nothing to help me. I can't understand whats the problem, please try me.
And one more thing:
If follow example instructions, filds "TextFilter filter" and "Lookup.getDefault()" in TextTopComponent.java in MavenWordEngine module are not existing. I'm add import org.openide.util.Lookup on top of TextTopComponent.java and trying to add import com.mycompany.textfilter.TextFilter. But TextFilter is not visible in TextTopComponent.java despite the fact that I maked the TextFilter Interface public. Will you explain my mistakes?

Replace the url-Element in your POM with this:
<url>https://repository.sonatype.org/service/local/repositories/atlassian/content</url>
Then the dependencies to org-openide-util and org-openide-util-lookup can be resolved.
The URL that you are using points to a single artifact and not to the whole repository.
Update
Maven says that it is looking for org.codeartisans.thirdparties.swing:org-openide-util:nbm:8.6.2 I don't know why. The artifcat type nbm belongs to netbeans, and I'm not familiar with netbeans. Try this:
<dependency>
<groupId>org.codeartisans.thirdparties.swing</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<version>8.3.1</version>
<type>jar</type>
</dependency>

Related

Running Maven for Gephi

I would like to create a plugin for Gephi but I got an error when running Maven and the project is not supported since 4 years... I already posted my question as an issue but I think no one will answer me now.
I forked the git and tried to follow instructions in the README to create my own plugin, but when I run this command :
mvn clean package
I constantly get this error :
[ERROR] Failed to execute goal on project gephi-plugins: Could not resolve dependencies for project org.gephi:gephi-plugins:pom:0.9.2: Failed to collect dependencies at org.gephi:gephi:tar.gz:linux:0.9.2 -> org.netbeans.cluster:platform:pom:RELEASE82: Failed to read artifact descriptor for org.netbeans.cluster:platform:pom:RELEASE82: Could not transfer artifact org.netbeans.cluster:platform:pom:RELEASE82 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [netbeans (http://bits.netbeans.org/nexus/content/groups/netbeans/, default, releases)] -> [Help 1]
I'm new with Maven and issues #77 and #214 didn't help me, I just followed instructions in the README file.
I followed the link given by the error and a blank page with this text appeared :
Repository decommissioned. Please refer to https://netbeans.apache.org/about/oracle-transition.html for more information.
And after clicking the link above, I thought this part was interesting :
As of March the 6th, 2021, we’ll be standing on our own feet, and all the Apache NetBeans Project source and convenience binaries will be hosted by the Apache Infra Team.
And then, a "new" code for handling netbeans repository
<build>
<repositories>
<repository>
<id>netbeans</id>
<name>NetBeans</name>
<url>http://netbeans.apidesign.org/maven2/</url>
</repository>
</repositories>
<build>
Is that possible that the pom.xml file is not up to date ? Or am I missing something ?
I spoke with someone who already used Maven at the office and he said that none of gephi repositories are working with Maven, all of them display the error.
Thanks for the help !
Finally the solution was quite simple :
The NetBeans repositories have indeed changed, so, in modules/pom.xml :
<repository>
<id>netbeans</id>
<name>NetBeans</name>
<url>http://bits.netbeans.org/nexus/content/groups/netbeans/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
We have to change the <url> tag to :
<url>http://netbeans.apidesign.org/maven2/</url>
I did that and it didn't work because my Maven version didn't support non secure url repositories (http) and I need to add a "s" in order to make it works.
<url>https://netbeans.apidesign.org/maven2/</url>
For a reason that I don't know, the project still not compile and we have to go to the parent pom.xml on the root folder and add the same NetBeans repository than above.
After doing that it compile.
I don't know if this is normal, but I'm new to Maven and I didn't know : if you want to use some gephi packages in your module (and wou want) you have to add them into module/YourModule/pom.xml in the <dependencies> tag ! Like that :
<dependencies>
<dependency>
<groupId>org.gephi</groupId>
<artifactId>layout-api</artifactId>
<version>0.9.2</version>
</dependency>
<dependency>
<groupId>org.gephi</groupId>
<artifactId>graph-api</artifactId>
<version>0.9.2</version>
</dependency>
<!-- ... -->
</dependencies>
I tested it with the GridLayout plugin from the Gephi Plugins Bootcamp and it worked.

selenium-central-framework in pom.xml

I am not able to find any hint about the issue that I am facing and hence posting my question here. Please apologize if it is something silly.
I have some working experience in selenium webdriver. However in my new project, I was asked to use an existing Selenium framework.
In the pom.xml, I am seeing the below dependency (I have edited xxx to avoid displaying the company name)
<dependencies>
<dependency>
<groupId>com.xxxqa.selenium</groupId>
<artifactId>selenium-central-framework</artifactId>
<version>2.0.18</version>
</dependency>
Question :
I couldn't understand from where that dependancy was taken from ?
Solution Tried :
I have tried searching in the maven repository still couldn't find
anything related to "selenium-central-framework"
I have checked the dependencies of selenium RC, but they seems to be different from the one that is present above.
I have researched whether any local jars were used and were linked
as dependancy. However I understand from maven repository, local
repositories will be linked with the tag "systemPath"
<dependency>
<groupId>ldapjdk</groupId>
<artifactId>ldapjdk</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\src\lib\ldapjdk.jar</systemPath>
</dependency>
</dependencies>
Note that the depedency used in my project doesn't have the tag "systemPath".
Is there anyway the external repositories could be added without mentioning systemPath ??
Please help, what could be that dependency ? How to find more information about it. Thanks a ton for your help.
I suggest you one of these approaches:
Jar file
If you have access to the jar file called : selenium-central-framework-2.0.18.jar, open a command line pointing to the folder of this jar and execute:
mvn install:install-file \
-Dfile=selenium-central-framework-2.0.18.jar \
-DgroupId=com.xxxqa.selenium \
-DartifactId=selenium-central-framework \
-Dversion=2.0.18 -Dpackaging=jar
Source code file
If you have the source code of : selenium-central-framework-2.0.18.jar, open a command line pointing to the folder of this source code and execute:
mvn clean install
After one of these approaches, selenium-central-framework-2.0.18.jar will be available in you local maven repository ($HOME/.m2) and your other java maven projects will be ready to use it as dependency:
<dependency>
<groupId>com.xxxqa.selenium</groupId>
<artifactId>selenium-central-framework</artifactId>
<version>2.0.18</version>
</dependency>
This is a workaround if you don't have a server to host an artifact repository management server like :
https://www.sonatype.com/nexus-repository-sonatype
https://www.jfrog.com/confluence/display/RTF/Maven+Repository
Explanation
Almost all free, public, safe, useful and cool java libraries are hosted in https://mvnrepository.com . So any person in the world can use it in their maven project with this piece in their pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
But in some cases, publish your source code to https://mvnrepository.com is not an option:
Oracle Driver. This driver (.jar) can only be downloaded from the official Oracle page. Private source code like IBM, Microsfot,etc
Source code of your company that should not be public.
Some super cool library that is only in github but not in the maven central repository.
So in this cases, the best and scalable solution is host and configure some artifact repository management server like :
https://www.sonatype.com/nexus-repository-sonatype
https://www.jfrog.com/confluence/display/RTF/Maven+Repository
This platforms are an emulation of https://mvnrepository.com . So with a minimal configuration:
You can host your special or private jars
Your maven projects could use this jars with the standrad xml dependency in pom.xml.
If you don't have a server to implement one of these platforms, the previous approaches could help you and get the same results

Maven repository that sometimes works

I hosted a java project on github.
The project is located here.
The project is really just a java library, and I wanted to create a maven repository for it. Because this is tricky, I followed a guide which explained me which project structure to follow. He applies a trick: create a 2nd branch named "repository". As you can see the jar files are in there.
That all went well, I made my first build, and then I created a java "Hello World" project to test if I could use this new maven dependency. So, I created a pom file with a dependency:
<dependency>
<groupId>brugo</groupId>
<artifactId>brugo</artifactId>
<version>0.1.0</version>
</dependency>
And to tell maven where to find this dependency, I added this one:
<repositories>
<repository>
<id>brugo</id>
<url>https://github.com/brugo/brugo/raw/repository/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
The good thing: sometimes it works.
The bad thing: sometimes it does not work.
And I am trying to find out what could be wrong. This is what IntelliJ looks like when things go wrong:
And I've seen this error message showing up:
[ERROR] Failed to execute goal on project xxx:
Could not resolve dependencies for project xxx:
Could not find artifact brugo:brugo:jar:0.1.0 in
brugo (https://github.com/brugo/brugo/raw/repository/) -> [Help 1]
I tried an mvn clean install -U several times, but without success.
I had the same problem on a different computer yesterday, then suddenly I got it to work without really knowing how.
Special thanks to #wargre for pointing me in this direction.
It's indeed easier (and more convenient) to set it up to be directly in the central maven repository.
http://central.sonatype.org/pages/ossrh-guide.html explains all the required steps. Here follows a summary.
First release:
Create a JIRA account and a project
Add plugins to the pom.xml file
Add more meta to the pom.xml
Download/install GPG and create keys
Create a settings.xml which contains your credentials.
Run mvn clean deploy
Verify the result in the staging repository
Release when happy, drop and retry while unsatisfied.
Post a comments on the JIRA ticket
Admire the result in the maven central repository.
Consecutive releases:
Update the version number in pom.xml
Run mvn clean deploy
Release (manual/automatic)

maven v3.0.5 cannot find sqoop artifact

i am trying to build my project with maven v3.0.5 and jdk 1.7. snippets of my pom xml looks like the following.
<properties>
<sqoop.version>1.4.4</sqoop.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.sqoop</groupId>
<artifactId>sqoop</artifactId>
<version>${sqoop.version}</version>
</dependency>
</dependencies>
when i run "mvn clean package" i see the following error:
Could not find artifact org.apache.sqoop:sqoop:jar:1.4.4 in central (http://repo.maven.apache.org/maven2)
usually and typically, i go to mvnrepository.com, and search for artifacts, and whatever artifacts i can find there, i have always been able to simply reference them in my pom.xml. according to this link, http://mvnrepository.com/artifact/org.apache.sqoop/sqoop/1.4.4, this artifact should exist?
i can't really browse http://repo.maven.apache.org/maven2.
Browsing for this directory has been disabled.
View this directory's contents on http://search.maven.org instead.
so i decided to use the search site for sqoop.
http://search.maven.org/#search%7Cga%7C1%7Csqoop
it seems to me that this artifact exists, but somehow, i can't access it. any ideas on what i'm doing wrong?
EDIT -
The Sqoop JAR varies based on what version of Hadoop you're using.
If you want to build against some Hadoop 0.23.x variant, what you need is the following:
<dependency>
<groupId>org.apache.sqoop</groupId>
<artifactId>sqoop</artifactId>
<version>1.4.4</version>
<classifier>hadoop23</classifier>
</dependency>
You will be able to see what classifiers are available using Eclipse. Right-click pom.xml, Maven --> Add Dependency. Type 'sqoop' in the search box, then expand the collapsed menu for org.apache.sqoop and note the options, hadoop23, hadoop100, etc.

Use maven to "extend" existing jar file

My project contains a couple of class which have to be integrated into an final jar file.
So my current "workflow" looks like:
mvn compile && jar uf contribution.jar -C target/classes .
I guess this could be done with the maven-jar plugin or through maven-assemblies but can't figure out how.
Simple - add the element <packaging>jar</packaging> to your pom.xml and invoke the following:
mvn package
See Maven build lifecycle for more information. It really is a must-read if you're planning to use Maven for you project.
Edit
Thanks for the update, I know understand what you mean. There may be a better way to do this, but this is what I use:
Maven will automatically include this jar if you add it as a dependency in the usual way, i.e:
<dependencies>
...
<dependency>
<groupId>some.group</groupId>
<artifactId>contribution</artifactId>
<version>1.0.0</version>
</dependency>
...
</dependencies>
The question is how to ensure that maven can find the jar? If the jar were in the Maven Global repository it would find it automatically, so always check this first. If not, then you will have to create your own repository to store custom jars. This may not be the most clever way to do it, but it's how I do it. Note that this is not the same thing as the cache stored in the .m2 folder.
Let's say we want to use c:\maven\repo as our local. To do this, first ensure the folder exists then add the following lines to your pom.xml:
<repositories>
<repository>
<id>my-repo</id>
<url>file://c:\maven\repo</url>
</repository>
</repositories>
Next, you will need to manually add the contribution jar to this repo. To do this execute the mvn deploy:deploy-file command and give it the appropriate values. See here for more information.
Now when build/compile/package your original project, it should include contribution.jar in the packaging as it is a dependency.
Hope this helps :)

Resources