代码之家  ›  专栏  ›  技术社区  ›  poseid

如何使用Maven构建独立的SWT GUI?

  •  0
  • poseid  · 技术社区  · 9 年前

    https://www.eclipse.org/swt/eclipse.php 关于如何使用Eclipse构建基于SWT的GUI,有一个很好的指南。

    [DEBUG] adding entry libswt-awt-cocoa-4626.jnilib
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3.747 s
    [INFO] Finished at: 2017-08-12T15:06:45+02:00
    [INFO] Final Memory: 15M/225M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project swtsandbox: Failed to create assembly: Error creating assembly archive jar-with-dependencies: Problem creating jar: invalid LOC header (bad signature) -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project swtsandbox: Failed to create assembly: Error creating assembly archive jar-with-dependencies: Problem creating jar: invalid LOC header (bad signature)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    

    <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>
    
      <groupId>pmu</groupId>
      <artifactId>swtsandbox</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>
    
      <name>swtsandbox</name>
      <url>http://maven.apache.org</url>
    
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <swt.version>4.6.1</swt.version>
      </properties>
    
    <repositories>
        <repository>
            <id>maven-eclipse-repo</id>
            <url>http://maven-eclipse.github.io/maven</url>
        </repository>
    </repositories>
    
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
    
        <!-- select prefered one, or move the preferred on to the top: -->
    
            <dependency>
                <groupId>org.eclipse.swt</groupId>
                <artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
                <version>${swt.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.swt</groupId>
                <artifactId>org.eclipse.swt.cocoa.macosx.x86_64</artifactId>
                <version>${swt.version}</version>
            </dependency>
      </dependencies>
    
    
    
    <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.6.2</version>
              <configuration>
                <!-- put your configurations here -->
              </configuration>
            </plugin>
    
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>pmu.swtsandbox.App</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
      <executions>
        <execution>
          <id>make-assembly</id> <!-- this is used for inheritance merges -->
          <phase>package</phase> <!-- bind to the packaging phase -->
          <goals>
            <goal>single</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    
          </plugins>
        </pluginManagement>
      </build>
    </project>
    

    Maven版本:

    Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
    Maven home: /usr/local/apache-maven-3.3.9
    Java version: 1.8.0_101, vendor: Oracle Corporation
    Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: "mac os x", version: "10.11.4", arch: "x86_64", family: "mac"
    p
    
    1 回复  |  直到 9 年前
        1
  •  1
  •   Andrei    9 年前

    看起来像你当地的一个或多个罐子 .m2 Maven存储库已损坏( jar-with-dependencies 首先尝试解包所有依赖项,以便将它们捆绑在同一个jar中)。

    您可以:

    • .平方米 并依靠Maven再次下载它们(the 在Windows安装程序中,存储库位于您当前的用户文件夹中;例如,对我来说,它位于 C:\Users\Andrei\.m2 )
    • 使用重新运行构建 -X 提供有关哪个特定jar导致问题的更多详细信息。那么你只能删除那个。

    install 在你的 .平方米