Maven failure to download swc files

2019-08-05 04:02发布

问题:

I'm trying to use Maven to build a Flex project using the Sonatype flexmojos. I've set up the project and the build mostly works until it tries to download various swc files from the Sonatype repository, eg.

Downloading: http://repository.sonatype.org/content/groups/flexgroup/com/adobe/flex/framework/framework/3.2.0.3958/framework-3.2.0.3958.rb.swc
Downloading: http://repository.sonatype.org/content/groups/flexgroup/com/adobe/flex/framework/flex/3.2.0.3958/flex-3.2.0.3958.swc
...

There are no errors in the download but for some reason the swc files do not appear in the local repository, and hence the build fails...

[ERROR] Failed to execute goal on project app: Could not resolve dependencies fo
r project ...:swf:1.0-SNAPSHOT: The following artifacts could not
 be resolved: com.adobe.flex.framework:flex:swc:3.2.0.3958...

Now, if I go to the Sonatype repository manually and download the swc and copy it into the correct location in the local repository then this will work. Equally, though, if I try to install the swc file using the Maven install goal then again it says the file is installed, but it is not in the repository, eg...

mvn install:install-file -Dfile=flex-3.2.0.3958 -DgroupId=com.adobe
.flex.framework -DartifactId=flex -Dversion=3.2.0.3958 -Dpackaging=swc

...reports a BUILD SUCCESS, but the swc file does not appear in the repository.

The pom.xml (which was generated from the flexmojos-archetypes-application mojo) is as follows:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.aaa.app</groupId>
  <artifactId>app</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>swf</packaging>

  <name>app Flex</name>

  <build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.5.0</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>com.adobe.flex.framework</groupId>
      <artifactId>flex-framework</artifactId>
      <version>3.2.0.3958</version>
      <type>pom</type>
    </dependency>

    <dependency>
      <groupId>com.adobe.flexunit</groupId>
      <artifactId>flexunit</artifactId>
      <version>0.85</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile><!--https://docs.sonatype.org/pages/viewpage.action?pageId=2949459-->
      <id>m2e</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.maven.ide.eclipse</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>0.9.9-SNAPSHOT</version>
            <configuration>
              <mappingId>customizable</mappingId>
              <configurators>
                <configurator id='org.maven.ide.eclipse.configuration.flex.configurator' />
              </configurators>
              <mojoExecutions>
                <mojoExecution>org.apache.maven.plugins:maven-resources-plugin::</mojoExecution>
              </mojoExecutions>
            </configuration>
          </plugin>
        </plugins>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-resources-plugin</artifactId>
              <version>2.4</version>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>

</project>

Does anyone know what I am doing wrong?! Thanks.

回答1:

Interesting. My first gut feeling is that they are being downloaded, but when they try to move it to the directory, something fails silently. I would check folder permissions. You maven file looks fine and the build says the same thing. There's something wrong with saving the swcs though. Have you tried this on another computer?



回答2:

All, Thanks for your help but I have found the problem. I am actually behind a proxy that has obviously been set up to somehow block this particular repository and swc files. This is strange because I can actually navigate to the file in the repo browser and download it manually, but when using the full URL it is blocked by the proxy! Unfortunately this wasn't really made very clear by Maven although an "Access denied" message was actually there embedded in a very long error message. The solution is to use https instead of http which can simply tunnel through the proxy.