Podstawowe klasy Java nadal w ścieżce klasy podczas budowania Androida na Maven

Mam dość dziwny problem spowodowany zarówno faktami, że implementacja Java java androida różni się od implementacji java słonecznej, jak i że podstawowe klasy java są nadal zawarte w ścieżce klas (na samym końcu) podczas mavennej kompilacji projekt android. Myślę, że rozwiązaniem jest brak klas java w ścieżce klasy, ale nie mogę znaleźć sposobu, aby to zrobić.

Zasadniczo istnieje klasa o nazwie AbstractExecutorService w java.util.concurrent (zarówno w systemie Android, jak i Java). Klasa java zawiera kilka metod o nazwie newTaskFor, których chciałbym używać w systemie Android, ale implementacja Androida ich nie ma. Nie ma problemu, po prostu je zaimplementuję (z kilkoma zmianami, takimi jak używanie Future zamiast RunnableFuture). Działa to dobrze w ant (narzędzie do budowania, z którego migrujemy).

Problem polega na tym, że kiedy maven próbuje skompilować moją klasę (która rozszerza AbstractExecutorService), zamiast dodawać moje metody do implementacji Androida, gdy ich nie znajdzie, kontynuuje ścieżkę klasy, znajduje metody java i narzeka, że ​​powrót typy nie pasują. Idealnie nie sądzę, aby klasy java były dostępne nawet podczas budowania Androida, ponieważ wszystko, co mogą zrobić, to sprawić, że myślisz, że możesz uruchomić metody, których naprawdę nie możesz, ale obecnie możesz uruchamiać różne rodzaje metod Java. dostępny w Androidzie i będzie kompilował dobrze (w maven).

Czy ktoś ma jakieś sugestie lub rozwiązania w tym zakresie? Ktoś wpadnie na coś podobnego?



Edytuj: tutaj jest odpowiednia część pom (pominięte repozytoria i takie):

<dependencies>
    <dependency>
        <groupId>org.beanshell</groupId>
        <artifactId>bsh</artifactId>
        <version>2.0b5</version>
        <optional>true</optional>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
        <optional>true</optional>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android-with-java</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.byteman</groupId>
        <artifactId>byteman-bmunit</artifactId>
        <version>2.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>bouncycastle</groupId>
        <artifactId>bcprov-jdk15</artifactId>
        <version>140</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
        <resource>
            <directory>conf</directory>
            <includes>
                <include>*.xml</include>
            </includes>
            <excludes>
                <exclude>*-service.xml</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>${project.build.directory}/schema</directory>
        </resource>
        <resource>
           <directory>${project.basedir}</directory>
           <includes>
              <include>INSTALL.html</include>
              <include>LICENSE</include>
              <include>README</include>
           </includes>
        </resource>
        <resource>
          <directory>${project.basedir}/lib</directory>
          <includes>
             <include>licenses/thirdparty*</include>
          </includes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <excludes>
                    <exclude>stuff/stuff/util/JUnitXMLReporter.java</exclude>
                </excludes>
            </configuration>
        </plugin>
       <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.7</version>
          <executions>
             <execution>
                <id>add-source</id>
                <phase>validate</phase>
                <goals>
                   <goal>add-source</goal>
                </goals>
                <configuration>
                   <sources>
                      <source>target/generated-sources</source>
                   </sources>
                </configuration>
             </execution>
             <execution>
                <id>add-test-source</id>
                <phase>validate</phase>
                <goals>
                   <goal>add-test-source</goal>
                </goals>
             </execution>
          </executions>
       </plugin>
       <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <phase>process-resources</phase>
                  <configuration>
                    <tasks>
                        <echo>Precompiling magic ids and protocol ids</echo>    
                        <xslt in="conf/stuff.xml" out="target/generated-sources/stuff/stuff/ClassMagicEncoding.java"
                            style="conf/stuff.xslt">
                            <param name="type" expression="Magic"/>
                        </xslt>
                        <xslt in="conf/stuff.xml" out="target/generated-sources/stuff/stuff/ClassProtocolEncoding.java"
                            style="conf/stuff.xslt">
                            <param name="type" expression="Protocol"/>
                        </xslt>
                    </tasks>
                  </configuration>
                </execution>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <property name="compile_classpath" refid="maven.compile.classpath"/>
                            <property name="plugin_classpath" refid="maven.plugin.classpath"/>
                            <delete dir="${project.build.directory}/schema" failonerror="false"/>
                            <mkdir dir="${project.build.directory}/schema"/>
                            <java classname="stuff.stuff.util.XMLSchemaGenerator">
                                <classpath>
                                    <pathelement path="${compile_classpath}"/>
                                    <pathelement path="${plugin_classpath}"/>
                                </classpath>
                                <arg line="-o ${project.build.directory}/schema"/>
                            </java>
                        </tasks>
                    </configuration>
                </execution>
            </executions>

            <configuration>
                <!-- prints the classpath to ensure correct jars are available -->
                <tasks>
                            <property name="compile_classpath" refid="maven.compile.classpath"/>
                    <echo>rawr=${compile_classpath}</echo>
                    <echo>java.class.path=${java.class.path}</echo>
                    <echo>CLASSPATH=${env.CLASSPATH}</echo>
                </tasks>
            </configuration>

            <dependencies>
                <dependency>
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                    <version>2.7.1</version>
                </dependency>
                <dependency>
                    <groupId>xalan</groupId>
                    <artifactId>serializer</artifactId>
                    <version>2.7.1</version>
                </dependency>
                <dependency>
                    <groupId>ant</groupId>
                    <artifactId>ant-antlr</artifactId>
                    <version>1.6.5</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-nodeps</artifactId>
                    <version>1.8.1</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Main-Class>stuff.stuff.Version</Main-Class>
                    <Implementation-Version>${project.version}</Implementation-Version>
                    <Export-Package>
                        schema;version=${project.version},
                        ${project.groupId}.*;version=${project.version}
                    </Export-Package>
                    <Bundle-RequiredExecutionEnvironment>J2SE-1.6</Bundle-RequiredExecutionEnvironment>
                </instructions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.2.0</version>
            <extensions>true</extensions>
                <configuration>
                    <sdk>
                         <platform>8</platform>
                    </sdk>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
        </plugin>
    </plugins>
</build>





Edit2: Oto błąd kompilacji, który otrzymuję.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project mystuff: Compilation failure: Compilation failure:
[ERROR] /home/stuff/stuff/ExecutionService.java:[775,28] <T>newTaskFor(java.lang.Runnable,T) in stuff.ExecutionService cannot override <T>newTaskFor(java.lang.Runnable,T) in java.util.concurrent.AbstractExecutorService; attempting to use incompatible return type
[ERROR] found   : java.util.concurrent.Future<T>
[ERROR] required: java.util.concurrent.RunnableFuture<T>
[ERROR] /home/stuff/ExecutionService.java:[791,28] <T>newTaskFor(java.util.concurrent.Callable<T>) in stuff.ExecutionService cannot override <T>newTaskFor(java.util.concurrent.Callable<T>) in java.util.concurrent.AbstractExecutorService; attempting to use incompatible return type
[ERROR] found   : java.util.concurrent.Future<T>
[ERROR] required: java.util.concurrent.RunnableFuture<T>
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project mystuff: Compilation failure

Uwaga: ExecutionService to klasa, która rozszerza usługę AbstractExecutorService. Jednak chcę, aby rozszerzyła TYLKO wersję Androida, a nie bazową wersję Java. Próbowałem nawet wstawić metody stub z newTaskFor do wersji android AbstractExecutorService (w myśli, że kompilator powinien wtedy założyć, że nadpisuję te metody, a nie bazowe java - chociaż powinienem zauważyć, że w kodzie nie ma @Override) ) ale nadal nie działa.

Nikt o nie nie prosił, ale oto moje deklaracje metod:

protected <T> Future<T> newTaskFor(Runnable runnable, T value) 
{
//stuff
}

protected <T> Future<T> newTaskFor(Callable<T> callable) 
{
//stuff
{

Moją obecną teorią jest to, że ma to coś wspólnego z typami szablonów, ale nie jestem pewien, jak to udowodnić lub naprawić.

Edytuj 6/30: Powinienem też zauważyć, że tak jestnie nowy kod. Ma ponad rok i od tego czasu doskonale się kompiluje. Jest częścią wielu stabilnych wydań. Jesteśmy teraz w trakcie migracji naszego procesu budowania do maven i dlatego staram się skonfigurować ten pakiet do prawidłowego budowania.

questionAnswers(1)

yourAnswerToTheQuestion