GAPID uses bazel, and has external dependency that uses maven. I get this error:
ERROR: C:/users/pemgithub/_bazel_pemgithub/3mdmxsrc/external/gapic_third_party/BUILD.bazel:19:1: no such package '#io_grpc_context//jar': Failed to fetch Maven dependency: Could not transfer artifact io.grpc:grpc-context:jar:1.16.1 from/to io_grpc_context (https://repo1.maven.org/maven2/): connect timed out and referenced by '#gapic_third_party//:grpc'
ERROR: Analysis of target '//:pkg' failed; build aborted: no such package '#io_grpc_context//jar': Failed to fetch Maven dependency: Could not transfer artifact io.grpc:grpc-context:jar:1.16.1 from/to io_grpc_context (https://repo1.maven.org/maven2/): connect timed out
INFO: Elapsed time: 11.014s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
Fetching #com_github_pkg_errors; Restarting. 10s
I think it's related to proxy (corporate network). I tried adding proxy settings to C:/users/pemgithub/.m2/settings.html. However, bazel maven does not seem to be using the proxy settings.
So I'd rather just download the jar files manually and tell bazel maven to use the local jar files. How do I do this?
Bazel currently (July 2019) does not support this properly. While rules_jvm_external is recommended as the successor to maven_jar, it does not read Maven's ~/.m2/settings.xml and it also does not supporting using already downloaded artifacts from ~/.m2/repository.
One workaround is to use your own little reverse proxy, which reads from ~/.m2/repository and tell Bazel to download from localhost. I've created bazel-maven-proxy for this purpose. It does support proxies the same way Bazel does, i.e. reading http(s) and no_proxy environment variables.
Please do not use the maven_jar rule. It is being deprecated in favor of the Maven resolver ruleset rules_jvm_external.
In rules_jvm_external, you can use a proxy through the HTTP_PROXY/HTTPS_PROXY environment variables (documentation), and set a custom repository URL with auth credentials (documentation).
Related
I got this error when deploying Maven through GitlabCI, docker image: maven:3-jdk-8.
Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.mycompany.app:app-all:0.9.3-SNAPSHOT:
Could not transfer artifact com.mycompany:parent:pom:8 from/to maven-default-http-blocker (http://0.0.0.0/):
Blocked mirror for repositories: [app-releases (http://nexus.mycompany.com/content/repositories/app-releases, default, releases+snapshots),
app-snapshots (http://nexus.mycompany.com/content/repositories/app-snapshots, default, releases+snapshots)] and 'parent.relativePath' points at wrong local POM # line 5, column 10
I found some answers here about editing the mirrors in the settings.xml file. I add the mirrors with blocked: false in /usr/share/maven/conf/settings.xml
<mirrors>
<mirror>
<id>app-releases</id>
<mirrorOf>app-releases</mirrorOf>
<url>http://nexus.mycompany.com/content/repositories/app-releases</url>
<blocked>false</blocked>
</mirror>
<mirror>
<id>app-snapshots</id>
<mirrorOf>app-snapshots</mirrorOf>
<url>http://nexus.mycompany.com/content/repositories/app-snapshots</url>
<blocked>false</blocked>
</mirror>
</mirrors>
But still got this error, I don't get why it search artifact in maven-default-http-blocker (http://0.0.0.0/) while option -X (debug) shows the settings.xml file is being used so the mirrors I set should be used.
1100 [DEBUG] Reading global settings from /usr/share/maven/conf/settings.xml
1100 [DEBUG] Reading user settings from /root/.m2/settings.xml
Did I make a mistake in the mirrors definition ?
This is probably due to Maven 3.8.1 blocking http repositories.
I would switch to https repositories if your company supports them.
You can do a mirroring in local. Add this in ~/.m2/settings.xml(which is a user-specific version of <maven_dir>/conf/settings.xml.
<settings>
<!-- if you need http connection, enable it and don't block -->
<mirrors>
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0</url>
<blocked>false</blocked>
</mirror>
</mirrors>
...
</settings>
I even changed the url to file:/home/<my_user>/.m2/repository, which solved my problem.
I was facing the same issues.
Maven Version 3.8.6
JDK Java17
The problem is maven was referring to some dependencies which are listed over http protocol, however with latest maven it comes with the mirror to block the http dependencies as it want to encourage or enforce dependencies only over https
Solution
Switch to the https dependencies.
If https version of dependencies are not available then we can locally suppress the error by commenting the http-block mirror
Below steps are for macos, so do relevant for your OS
Run mvn --version to find the location of maven installation
bash-3.2$ mvn --version
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /usr/local/Cellar/maven/3.8.6/libexec
Now go to conf and open settings.xml
Comment the below mirror
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
Save it and re run the maven job, it should fix your issue.
I created a Bazel archive tar using the steps provides in the Bazel docs. Most of the packages are being loaded locally except for this one. Please see error below.
C:\Developers\examples-master\java-tutorial>bazel build --distdir=C:\Developers\bazel-tar //:ProjectRunner Starting local Bazel server and connecting to it... INFO: Repository remotejdk11_win instantiated at: no stack (--record_rule_instantiation_callstack not enabled) Repository rule http_archive defined at: C:/users/syuopm/_bazel_syuopm/v5bxa2ms/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in WARNING: Download from https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-win_x64.zip failed: class java.io.IOException connect timed out ERROR: An error occurred during the fetch of repository 'remotejdk11_win': java.io.IOException: Error downloading [https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-win_x64.zip] to C:/users/syuopm/_bazel_syuopm/v5bxa2ms/external/remotejdk11_win/zulu11.37.17-ca-jdk11.0.6-win_x64.zip: connect timed out INFO: Repository remote_java_tools_windows instantiated at: no stack (--record_rule_instantiation_callstack not enabled) Repository rule http_archive defined at: C:/users/syuopm/_bazel_syuopm/v5bxa2ms/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in ERROR: C:/users/syuopm/_bazel_syuopm/v5bxa2ms/external/bazel_tools/tools/jdk/BUILD:492:6: #bazel_tools//tools/jdk:remote_jdk11 depends on #remotejdk11_win//:jdk in repository #remotejdk11_win which failed to fetch. no such package '#remotejdk11_win//': java.io.IOException: Error downloading [https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-win_x64.zip] to C:/users/syuopm/_bazel_syuopm/v5bxa2ms/external/remotejdk11_win/zulu11.37.17-ca-jdk11.0.6-win_x64.zip: connect timed out ERROR: Analysis of target '//:ProjectRunner' failed; build aborted: Analysis failed INFO: Elapsed time: 68.089s INFO: 0 processes. FAILED: Build did NOT complete successfully (16 packages loaded, 305 targets configured)
It seems to be a network issue most likely due to some firewall or proxy server sitting between your computer and the Bazel repo. The following download failed:
Download from https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-win_x64.zip failed
I suggest you download the file manually and follow the guidance here:
A work around is to fetch the files manually and put them in a directory specified via the --distdir option.
Those are mirror artifacts which are updated by the bazel team here. I think the archive URL which you mentioned above is mirrored and updated with latest files. If you see such observations may be you can raise the issues in that specific templates.
Bazel is trying to download packages on python test. I've wrote a simple python code, and a test file testing it.
I'm running `bazel test //test:python-test and I get the following error:
/Path/to/build/external/bazel_tools/tools/jdk/build:305:1: no such package '#remotejdk_linux//': java.io.IOException: error downloading [ unknown host: mirror.bazel.build and referenced by '#bazel_tools//tools/jdk:remote_jdk'
Now, that's obviously a problem in my workspace, where we work offline. Is there any way to work offline with bazel?
Using the following flags will force bazel to use your local java:
--host_javabase=#bazel_tools//tools/jdk: absolute_javabase --define=ABSOLUTE_JAVABASE=/path/to/my/jdk
You can add them to your local .bazelrc file to write shorter command-line
You can manually download requested artifact and put it in cache before calling build. Bazel will not download artifact if it's already exists in local cache.
From Eclipse mars version, pom.xml - Run As - maven clean and i got the following error message with Build Failure.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project testing-framework:
Execution default-clean of goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean failed: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved:
Failed to collect dependencies at org.apache.maven.plugins:maven-clean-plugin:jar:2.5 -> org.apache.maven:maven-plugin-api:jar:2.0.6:
Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6:
Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]
I had the same problem. I solved it by killing java.exe process in Task Manager and re-excuting maven clean install.
Unknown host repo.maven.apache.org
sounds like a networking issue. Maybe check wether you need to supply proxy information within your settings.xml. Here's the documentation on how to supply one.
Alternativly, Eclipse might expose its own proxy settings to its Maven integration, but I'm not sure about that, I only use Maven from console. Still, its worth the check and maybe the config.
I have a few questions about Maven and Eclipse which I do not know much about them. I'm new to all these tools. Let me describe what I've done:
1 - installed apache-maven-3.3.9 on my window and placed at "C:\Program Files (x86)\apache-maven-3.3.9".
2 - Added MAVEN_HOME (and M2_HOME) environment variables.
3 - Added the "C:\Program Files (x86)\apache-maven-3.3.9\bin" to the Path environment variable.
4 - Set a proxy for Maven download by creating a xml file under ${user.home".m2]settings.xml. The content of the settings.xml is:
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>https</protocol>
<host>www.github.com</host>
<port>8080</port>
<nonProxyHosts>www.google.com</nonProxyHosts>
</proxy>
</proxies>
</settings>
5 - Tested and see if the Maven was properly installed:
C:\>mvn --version
C:\
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5 2015-11-10T11:41:47-05:00)
Maven home: C:\Program Files (x86)\apache-maven-3.3.9
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jdk1.8.0_101\jrr
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2008 r2", version: "6.1", arch: "x86", family: "dos"
6 - Tried to generate archetype and got a bunch of errors. Only one error is shown below. Basically, Maven tries to download the plugin but fails. I doubt the errors are caused by internet connection, but I don't know where else I need to look in order to fix this issue. The reason I said I doubted it was the internet connection issue is because I configure my POM file with the external jars on the web and all were downloaded correctly.
C:\>mvn archetype:generate
C:\
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or on
e of its dependencies could not be resolved: Failed to read artifact descriptor
for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-install-plugin/2.4/maven-install-plugin-2.4.pom
Terminate batch job (Y/N)? y
C:\>
So... that is the maven plugins downloading problem.
And here is the Eclipse problem:
1 - Installed Eclipse Neon.
2 - Tried to add the Maven plugins and it say that all maven plugins already installed. I did the Maven plugins before with the previously installed Neon. Then I deleted the Neon Eclipse because it fails to create a simple Maven-archetype project. Then I re-installed the Neon Eclipse. But before I re-installed Eclipse I already deleted all previously-installed Eclipse folders but I do not know where the Eclipse keeps all of Maven info. When the newly-installed Eclipse tries to download the Maven plugins, it recognized that all of the Maven plugins were already installed. I have no ideas where Eclipse keeps all those info about Maven plugins?
3 - Tried again to create an simple Maven-archetype project, then I got this error message:
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): connect timed out
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.1 from/to central (https://repo.maven.apache.org/maven2): connect timed out
So.. basically, it is the same error message that Maven has.
Questions:
1 - What are the things I need to do get Maven plugins download via command line?
2 - Similarly, what are the things I need to do to get Eclipse to create a simple maven-archetype project?
I did checked out all of questions and answers about the issues of Maven not being able to download the plugins. I did try everything in last several days but no prevail. I understand that the answers/solutions are good but they do not work for me. Maybe I need to other things that I don't know where else I need to look for?
3 - Let say that after all these efforts fail, can I manually download the Maven plugins and configure them via my POM.xml? I checked the apache Maven website and it seems that the answer is "yes" but it does not provide the "how". I know it is NOT the best solution for maven plugins download but if I couldn't fix the download issue, the I will have to resort to the manual download and then configure the POM file.
Would you please show me how to configure the POM.xml file with the Maven Plugins?
Sorry about the long questions, but I'm new to these tools and I'm just trying to get a simple Java project built by Maven via Eclipse.
The proxy in the settings file is for case where the machine you run is behind a proxy (lets say a corporate proxy). You have put github.com as the proxy host which is not right.
If you have the maven installation bundled with eclipse that provides you integration with the IDE itself during the maven lifecycle process. You are however free to add a maven installation of your own by adding a existing maven installation from eclipse as well (you want to use a specific installation of maven with its settings).
If you are behind a corporate proxy , you will have to get the proxy through which the machine connects to the internet. You can then add that detail into the proxy settings in maven. In the case that your corporate proxy uses a dynamic proxy (e.g. a .pac file opposed to static host) you will need to look at options like CNTLM or wagon to work around and get it running.