使用XText项目的Maven依赖项

时间:2017-09-28 10:45:10

标签: java eclipse maven xtext tycho

我创建了一个XText项目并选择了构建系统作为Maven。该项目有Pom文件。我已经在pom文件中指定了依赖项,但无法解析依赖项。我不确定如何在类路径中包含maven依赖项。 pom文件看起来像这样。

<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>
    <parent>
        <groupId>com.xtext.company.vocabulary</groupId>
        <artifactId>com.xtext.company.vocabulary.parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>com.xtext.company.vocabulary</artifactId>
    <packaging>eclipse-plugin</packaging>

    <dependencies>
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-core</artifactId>
            <version>3.0.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.4.0</version>
                <executions>
                    <execution>
                        <id>mwe2Launcher</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
                    <arguments>
                        <argument>/${project.basedir}/src/com/xtext/scania/GenerateVocabulary.mwe2</argument>
                        <argument>-p</argument>
                        <argument>rootPath=/${project.basedir}/..</argument>
                    </arguments>
                    <classpathScope>compile</classpathScope>
                    <includePluginDependencies>true</includePluginDependencies>
                    <cleanupDaemonThreads>false</cleanupDaemonThreads><!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=475098#c3 -->
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.eclipse.emf</groupId>
                        <artifactId>org.eclipse.emf.mwe2.launch</artifactId>
                        <version>2.9.0.201605261059</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.xtext</groupId>
                        <artifactId>org.eclipse.xtext.common.types</artifactId>
                        <version>${xtextVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.xtext</groupId>
                        <artifactId>org.eclipse.xtext.xtext.generator</artifactId>
                        <version>${xtextVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.xtext</groupId>
                        <artifactId>org.eclipse.xtext.xbase</artifactId>
                        <version>${xtextVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.xtext</groupId>
                        <artifactId>xtext-antlr-generator</artifactId>
                        <version>[2.1.1, 3)</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.eclipse.xtend</groupId>
                <artifactId>xtend-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets combine.children="append">
                        <fileset>
                            <directory>${basedir}/../com.xtext.scania.vocabulary/src-gen/</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>${basedir}/../com.xtext.scania.vocabulary.tests/src-gen/</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>${basedir}/../com.xtext.scania.vocabulary.ide/src-gen/</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>${basedir}/../com.xtext.scania.vocabulary.ui/src-gen/</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>${basedir}/../com.xtext.scania.vocabulary.ui.tests/src-gen/</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>${basedir}/model/generated/</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.codehaus.mojo
                                        </groupId>
                                        <artifactId>
                                            exec-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.2.1,)
                                        </versionRange>
                                        <goals>
                                            <goal>java</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

父母pom看起来像这样:

<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>com.xtext.company.vocabulary</groupId>
    <version>1.0.0-SNAPSHOT</version>
    <artifactId>com.xtext.company.vocabulary.parent</artifactId>
    <packaging>pom</packaging>

    <properties>
        <tycho-version>1.0.0</tycho-version>
        <xtextVersion>2.12.0</xtextVersion>
        <project.build.sourceEncoding>windows-1252</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <jena.version>3.0.1</jena.version>

    </properties>
    <modules>
        <module>com.xtext.company.vocabulary</module>
        <module>com.xtext.company.vocabulary.ide</module>
        <module>com.xtext.company.vocabulary.ui</module>
        <module>com.xtext.company.vocabulary.target</module>
        <module>com.xtext.company.vocabulary.tests</module>
        <module>com.xtext.company.vocabulary.ui.tests</module>
    </modules>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho-version}</version>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>target-platform-configuration</artifactId>
                <version>${tycho-version}</version>
                <configuration>
                    <target>
                        <artifact>
                            <groupId>com.xtext.scania.vocabulary</groupId>
                            <artifactId>com.xtext.scania.vocabulary.target</artifactId>
                            <version>${project.version}</version>
                        </artifact>
                    </target>
                    <environments>
                        <environment>
                            <os>macosx</os>
                            <ws>cocoa</ws>
                            <arch>x86_64</arch>
                        </environment>
                        <environment>
                            <os>win32</os>
                            <ws>win32</ws>
                            <arch>x86_64</arch>
                        </environment>
                        <environment>
                            <os>linux</os>
                            <ws>gtk</ws>
                            <arch>x86_64</arch>
                        </environment>
                    </environments>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.xtend</groupId>
                    <artifactId>xtend-maven-plugin</artifactId>
                    <version>${xtextVersion}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                                <goal>xtend-install-debug-info</goal>
                                <goal>testCompile</goal>
                                <goal>xtend-test-install-debug-info</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <outputDirectory>${basedir}/xtend-gen</outputDirectory>
                        <testOutputDirectory>${basedir}/xtend-gen</testOutputDirectory>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <filesets>
                            <fileset>
                                <directory>${basedir}/xtend-gen</directory>
                                <includes>
                                    <include>**/*</include>
                                </includes>
                                <directory>${basedir}/xtend-gen</directory>
                                <includes>
                                    <include>**/*</include>
                                </includes>
                            </fileset>
                        </filesets>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.apache.maven.plugins
                                        </groupId>
                                        <artifactId>
                                            maven-resources-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.4.3,)
                                        </versionRange>
                                        <goals>
                                            <goal>resources</goal>
                                            <goal>testResources</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.codehaus.mojo
                                        </groupId>
                                        <artifactId>
                                            build-helper-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.9.1,)
                                        </versionRange>
                                        <goals>
                                            <goal>add-resource</goal>
                                            <goal>add-source</goal>
                                            <goal>add-test-resource</goal>
                                            <goal>add-test-source</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.eclipse.tycho
                                        </groupId>
                                        <artifactId>
                                            tycho-compiler-plugin
                                        </artifactId>
                                        <versionRange>
                                            [0.23.1,)
                                        </versionRange>
                                        <goals>
                                            <goal>compile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.eclipse.tycho
                                        </groupId>
                                        <artifactId>
                                            tycho-packaging-plugin
                                        </artifactId>
                                        <versionRange>
                                            [0.23.1,)
                                        </versionRange>
                                        <goals>
                                            <goal>build-qualifier</goal>
                                            <goal>build-qualifier-aggregator</goal>
                                            <goal>validate-id</goal>
                                            <goal>validate-version</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
                <plugin>
                    <!-- Can be removed after first generator execution https://bugs.eclipse.org/bugs/show_bug.cgi?id=480097 -->
                    <groupId>org.eclipse.tycho</groupId>
                    <artifactId>tycho-compiler-plugin</artifactId>
                    <version>${tycho-version}</version>
                    <configuration>
                        <compilerArgument>-err:-forbidden</compilerArgument>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <repositories>
        <repository>
            <id>codehaus-snapshots</id>
            <name>disable dead 'Codehaus Snapshots' repository, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=481478</name>
            <url>http://nexus.codehaus.org/snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>codehaus-snapshots</id>
            <name>disable dead 'Codehaus Snapshots' repository, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=481478</name>
            <url>http://nexus.codehaus.org/snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <dependencies>
    </dependencies>
</project>

我是XText和Tychobuild的新手。我想在XText项目中使用maven依赖项。我在这里错过了什么?任何帮助都感激不尽。

1 个答案:

答案 0 :(得分:0)

父pom中的您的部分指定了死nexus存储库。请尝试使用中央存储库:

http://repo.maven.apache.org/maven2/ http://central.maven.org/maven2