如何解决此Gradle构建错误 - 无法找到注释?

时间:2013-04-02 17:24:31

标签: java build annotations gradle

<?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">
<parent>
    <groupId>org.atmosphere.samples</groupId>
    <artifactId>atmosphere-samples</artifactId>
    <version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.atmosphere.samples</groupId>
<artifactId>atmosphere-atmospherehandler-pubsub2</artifactId>
<packaging>war</packaging>
<version>1.1.0-SNAPSHOT</version>
<name>atmosphere-atmospherehandler-pubsub2</name>
<url>http://maven.apache.org</url>

<dependencies>
    <dependency>
        <groupId>org.atmosphere</groupId>
        <artifactId>atmosphere-jquery</artifactId>
        <version>${project.version}</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>org.atmosphere</groupId>
        <artifactId>atmosphere-runtime</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-servlet_3.0_spec</artifactId>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback-version}</version>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>${logback-version}</version>
    </dependency>

    <!-- This is ONLY required if you use Atmosphere's annotation. If you use atmosphere.xml, not required -->
    <dependency>
        <groupId>eu.infomas</groupId>
        <artifactId>annotation-detector</artifactId>
        <version>3.0.0</version>
    </dependency>
</dependencies>

apply plugin: 'war'
apply plugin: 'jetty'

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'org.atmosphere', name: 'atmosphere-runtime', version: '1.0.12'
    compile group: 'org.atmosphere', name: 'atmosphere-jquery', version: '1.0.12'
    compile group: 'ch.qos.logback', name: 'logback-core', version: '1.0.7'
    compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.6'
    compile group: 'eu.infomas', name: 'annotation-detector', version: '3.0.0'
    compile group: 'org.apache.geronimo.specs', name: 'geronimo-servlet_3.0_spec',   version: '1.0'
}

httpPort = 8085
stopPort = 9451
stopKey = 'monkey'

以上是Atmosphere网络套接字示例程序的maven pom.xml(可在https://github.com/Atmosphere/atmosphere/tree/master/samples获得)。我正在尝试将maven构建转换为Gradle,我的注释会出错。

:compileJava
/home/shawn/dev/web/atmosphere/samples/jquery-atmospherehandler-pubsub2/src/main/java/org/atmosphere/samples/pubsub2/AtmosphereHandlerPubSub.java:18: error: cannot find symbol
import org.atmosphere.config.service.Get;
                                    ^
  symbol:   class Get
  location: package org.atmosphere.config.service
/home/shawn/dev/web/atmosphere/samples/jquery-atmospherehandler-pubsub2/src/main/java/org/atmosphere/samples/pubsub2/AtmosphereHandlerPubSub.java:19: error: cannot find symbol
import org.atmosphere.config.service.ManagedService;
                                    ^
  symbol:   class ManagedService
  location: package org.atmosphere.config.service
/home/shawn/dev/web/atmosphere/samples/jquery-atmospherehandler-pubsub2/src/main/java/org/atmosphere/samples/pubsub2/AtmosphereHandlerPubSub.java:20: error: cannot find symbol
import org.atmosphere.config.service.Message;
                                    ^
  symbol:   class Message
  location: package org.atmosphere.config.service
/home/shawn/dev/web/atmosphere/samples/jquery-atmospherehandler-pubsub2/src/main/java/org/atmosphere/samples/pubsub2/AtmosphereHandlerPubSub.java:36: error: cannot find symbol
@ManagedService(path = "/")
 ^
  symbol: class ManagedService
/home/shawn/dev/web/atmosphere/samples/jquery-atmospherehandler-pubsub2/src/main/java/org/atmosphere/samples/pubsub2/AtmosphereHandlerPubSub.java:39: error: cannot find symbol
    @Get
     ^
  symbol:   class Get
  location: class AtmosphereHandlerPubSub
/home/shawn/dev/web/atmosphere/samples/jquery-atmospherehandler-pubsub2/src/main/java/org/atmosphere/samples/pubsub2/AtmosphereHandlerPubSub.java:44: error: cannot find symbol
    @Message
     ^
  symbol:   class Message
  location: class AtmosphereHandlerPubSub
6 errors
:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.821 secs

上面的错误和来源......

package org.atmosphere.samples.pubsub2;

import org.atmosphere.config.service.Get;
import org.atmosphere.config.service.ManagedService;
import org.atmosphere.config.service.Message;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.Broadcaster;
import org.atmosphere.cpr.BroadcasterFactory;

import java.io.IOException;

@ManagedService(path = "/")
public class AtmosphereHandlerPubSub  {

    @Get
    public void onRequest(AtmosphereResource r) throws IOException {
        r.setBroadcaster(lookupBroadcaster(r.getRequest().getPathInfo()));
    }

    @Message
    public String onMessage(String message) throws IOException {
        if (message != null && message.indexOf("message") != -1) {
            return (message.substring("message=".length()));
        } else {
            return "=error=";
        }
    }

    Broadcaster lookupBroadcaster(String pathInfo) {
        String[] decodedPath = pathInfo.split("/");
        Broadcaster b = BroadcasterFactory.getDefault().lookup(decodedPath[decodedPath.length - 1], true);
        return b;
    }

}

我确定这是一个菜鸟问题,但我找不到答案。

编辑:似乎pom.xml的“父”部分是问题,那里有更多的依赖项。我仍然找不到解决这个问题所需的那个。

0 个答案:

没有答案