Maven proxy configuration not working - eclipse

I know there are already many questions on this subject but somehow I can't work out how to use maven 3.0.5 behind a proxy.
The settings.xml file inside my .m2/ folder looks like this
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>http-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxyname</host>
<port>8080</port>
<username>Domain\user</username>
<password>password</password>
<nonProxyHosts>127.0.0.1</nonProxyHosts>
</proxy>
</proxies>
</settings>
I also added wagon-http-lighteweight-2.2.jar to MAVEN_HOME/lib/ext.
I'm using maven inside eclipse, but it's showing the correct settings file in eclipse maven properties.
Despite having all these settings I still get the following error message after importing a spring boot project:
Project build error: Non-resolvable parent POM for <ProjectName>:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.4.1.RELEASE from/to central (https://repo.maven.apache.org/maven2): Failed to authenticate with proxy and 'parent.relativePath' points at no local POM

After running maven with the -X switch like Little Santi suggested I saw that the proxy is not the problem but the company I work in uses lokal maven repositories which I had to include.
I added these repositories and mirrors to my settings.xml and now it's working fine.

Related

[New maven project in eclipse on MacOS]How to solve "Could not resolve archetype..."?

I am working on MacOS 10.14.6 with:
java version "12.0.2" 2019-07-16
Apache Maven 3.6.2
Eclipse IDE for Java Developers Version: 2019-06 (4.12.0)
When I tried to open a new maven project, the following error happened:
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.1
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org
I have tried the following:
set proxy in settings.xml and place it in .m2 folder
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<username>****</username>
<password>****</password>
<host>proxy****</host>
<port>**</port>
<nonProxyHosts></nonProxyHosts>
</proxy>
</proxies>
set proxy in network connections in eclipse
configure the settings.xml paths of global and user settings in eclipse as the settings.xml in the installed folder
delete .m2 folder and restart eclipse
add remote archetype catalog with the path
http://repo1.maven.org/maven2/archetype-catalog.xml
May I have your kind help to solve this?
The issue is solved by adding the mirror content in the settings.xml. https://maven.apache.org/guides/mini/guide-mirror-settings.html

Sonar `should be relative to project baseDir` error in travis

Some time between the 11th September and the 14th September, running sonar through our travis build started failing with an org.eclipse.dawnsci.targetplatform should be relative to project baseDir error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project org.eclipse.scanning: Dir /home/travis/build/eclipse/org.eclipse.dawnsci/org.eclipse.dawnsci.targetplatform should be relative to project baseDir -> [Help 1]
Looking through the pom.xml the org.eclipse.dawnsci module does stand out as being different to all of the others:
<modules>
<module>org.eclipse.scanning.target.platform</module>
<module>../org.eclipse.dawnsci</module>
<module>org.eclipse.scanning.api</module>
...
</modules>
I have tried updating sonar-project.properties from
sonar.exclusions=**/*.xml,**/*.class
to each of the following:
sonar.exclusions=**/*.xml,**/*.class,../org.eclipse.dawnsci
sonar.exclusions=**/*.xml,**/*.class,org.eclipse.dawnsci*
sonar.exclusions=**/*.xml,**/*.class,org.eclipse.dawnsci**
but none of these changes helped.
After previous problems I have added --fail-never to the mvn -q sonar:sonar command in .travis.yml so this problem won't prevent pull requests being merged, but it would be nice to have sonar reports on our repo again.
Any suggestions about how I can fix our travis build would be appreciated?
We changed the way we validate project layout, and it leads to this error. A ticket was created to track this change, and we are currently discussing options (like updating the SonarQube Scanner for Maven). Feel free to follow it for updates, and sorry for the inconvenience.
For your specific case, one workaround is to create a build profile, and exclude module ../org.eclipse.dawnsci when running the SonarCloud analysis. Or move the module to be under the project basedir (and avoid using .. in module location).
As a side note, there is no point maintaining the file sonar-project.properties if you are using the Scanner for Maven (mvn sonar:sonar) since the Scanner for Maven will only read configuration from pom.xml.
As suggested by Julien H. - SonarSource Team adding a profile did solve this problem.
In the pom.xml I changed
<modules>
<module>org.eclipse.scanning.target.platform</module>
<module>../org.eclipse.dawnsci</module>
...
</modules>
to
<profiles>
<profile>
<id>externalModules</id>
<activation><activeByDefault>true</activeByDefault></activation>
<modules>
<module>../org.eclipse.dawnsci</module>
</modules>
</profile>
</profiles>
<modules>
<module>org.eclipse.scanning.target.platform</module>
...
</modules>
so that the module is included by default.
I then added -P !externalModules to my mvn sonar:sonar command in .travis.yml so that it was excluded when running sonar analysis.
I stumbled over the same problem and finally came to the conclusion that this has all been fixed in the latest sonar-maven-plugin 3.4. You can simply upgrade your dependency to this:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>

how to solve proxy using maven (IN Eclipse)

when I want to create a new maven webApp project using Eclipse i get this
Error :
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
here is a part of my setting.xml :
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>myUsername</username>
<password>myPasseword</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
Thank you
Here is my configuration :
#MadJlzz , using Goals in commande line works perfectly
But, in eclipse still the problem

I can't figure out how to use Apache Ivy

I want to have a JAR file repository on my local network so all other Eclipse users use the same JAR files in Repository for their dependencies. I don't want Maven or Ant, I just want to use Ivy to share my JAR files, how do I do this? which XML file should I use? Can't find a simple solution online.
For start here is an example of ivy.xml file
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info
organisation="[your organization]"
module="your module[for example commons-io]"
status="integration">
</info>
<publications>
<artifact name="[your jar name]" ext="jar"/>
</publications>
Second an important step is creating an ivy.settings file.
<ivysettings>
<resolvers>
<filesystem name="public">
<ivy pattern="/path/to/my/public/rep/[organisation]/[module]/ivy-[revision].xml" />
<artifact pattern="/path/to/my/public/rep/[organisation]/[module]/[artifact]-[revision].[ext]" />
</filesystem>
</resolvers>
</ivysettings>
This is just part of the ivy.setting file and the resolver name should represent
your own repository for publications and downloading jars from your local network .
Read more about Adjusting ivy settings on http://ant.apache.org/ivy/history/2.1.0/tutorial/defaultconf.html
.
How ever ivy can't do the publish work for you ,and you will have to use ant
just small build.xml file .
Read on apache site http://ant.apache.org/ivy/history/2.2.0/use/publish.html
I hope it will be helpful.

Beginner Steps to Configure a Java Project to Build with Apache Maven

I've been given the task of migrating an existing project -- formerly built with Ant -- to use Apache Maven. I'm brand new to the entire concept, though I've spent the last several hours doing as much research as I can on the subject. Sadly, I'm having some proxy issues when it comes to installing things like m2e and Eclipse IAM, so everything must be done from the command prompt. As of right now, I do have maven installed properly; the trick now is to use it in my project rather than Ant. I've looked online and found a few tutorials, but they are all too vague for me considering my lack of experience with all of this. If anyone can break the steps down for me one-by-one in a detailed manner, that would be more than amazing. On a side note, I've been told to add the following to the local Maven Settings:
<settings>
<servers>
<server>
<id>local_tomcat</id>
<username>admin</username>
<password>tomcat</password>
</server>
<server>
<id>artifactory</id>
<username>user</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<name>Artifactory</name>
<url>https://jenkins.web.jw.local/artifactory/repo1</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.jw.local</host>
<port>80</port>
<username>user</username>
<password>password</password>
<nonProxyHosts>*.jw.local</nonProxyHosts>
</proxy>
</proxies>
</settings>
With the obvious username and password information filled in. I think I've managed that thus far by simply adding the necessary blocks into the settings.xml file under my ApacheMaven\conf directory. Other than that single step, I'm pretty much lost. Again, any help, especially that of a detailed tutorial in terms of command line instructions to build this project would be wonderful. Oh, and on another side-note, I am using Eclipse... Not sure if that would matter much.
EDIT: Considering Petr Kozelka's answer, I've attempted to make a pom.xml file for my project. Here's what I have so far...
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>appName</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>Application Name</name>
<description>Yadda Yadda</description>
<build>
<plugins>
</plugins>
</build>
<dependencies>
</dependencies>
<repositories>
</repositories>
</project>
Is this heading in the right direction? Also, do I need to construct the archetype.xml file myself, or will Maven do that through the command line somehow? If I need to do it myself, this is what I've come up with thus far:
<archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>lighthouse</id>
<sources>
<source>src/com/jeldwen/lighthouse/controller/AddTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/BugController.java</source>
<source>src/com/jeldwen/lighthouse/controller/DeleteTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/EnterTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/ModifyTimeController.java</source>
<source>src/com/jeldwen/lighthouse/controller/PersonController.java</source>
<source>src/com/jeldwen/lighthouse/controller/ProjectController.java</source>
<source>src/com/jeldwen/lighthouse/controller/TimeController.java</source>
<source>src/com/jeldwen/lighthouse/model/Area.java</source>
<source>src/com/jeldwen/lighthouse/model/Bug.java</source>
<source>src/com/jeldwen/lighthouse/model/DBModel.java</source>
<source>src/com/jeldwen/lighthouse/model/DefaultModel.java</source>
<source>src/com/jeldwen/lighthouse/model/JWModel.java</source>
<source>src/com/jeldwen/lighthouse/model/JWTime.java</source>
<source>src/com/jeldwen/lighthouse/model/Person.java</source>
<source>src/com/jeldwen/lighthouse/model/Project.java</source>
<source>src/com/jeldwen/lighthouse/util/Lighthouse.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseApplicationListener.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseServlet.java</source>
<source>src/com/jeldwen/lighthouse/util/LighthouseSystemProperties.java</source>
<source>src/com/jeldwen/lighthouse/LighthouseApp.java</source>
</sources>
<testSources>
<!-- None -->
</testSources>
<allowPartial>true</allowPartial>
</archetype>
First of all: if you wish to customize settings.xml, do not touch the one in maven distro - instead, create a new file in $HOME/.m2/settings.xml where maven finds and uses it.
As the very first step, I recommend you to not use settings.xml at all.
Create a supersimple maven project, and try to compile it:
mvn clean install
Second step
Use very simple settings.xml:
you probably do not need proxy
servers part is needed only for publishing artifacts to a maven repository; that's not important at the beginning
here it is:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<id>repos</id>
<mirrorOf>*</mirrorOf>
<name>internal mirror</name>
<url>https://jenkins.web.jw.local/artifactory/repo1</url>
</mirror>
</mirrors>
<!-- TODO: the proxy part here -->
</settings>
This assumes that you use inhouse maven repository, for instance Nexus or Artifactory.
Using maven repo makes only sense if your projects are not happy with deps available in the Maven Central Repository - otherwise, you can safely go without it. (let's neglect the performance effect of repoman for now)
Now, add some java sources, dependencies etc. - and watch how new depenencies get automatically downloaded to your local repository...
Third step
Learn how to add further repositories to your repository manager (group "public" on Nexus)...
The rest is probably subject of further research.