Base java classes still in the classpath during maven android build -
i'm having rather strange problem caused both facts android java implementation differs sun java implementation , base java classes still included in classpath (all way @ end) during maven build of android project. think solution not have java classes on classpath, can't seem find way this.
basically, there class called abstractexecutorservice in java.util.concurrent (in both android , java). java class contains couple methods called newtaskfor i'd use in android, android implementation doesn't have them. no problem, i'll implement them (with few changes such using future instead of runnablefuture). works fine in ant (the build tool migrating away from).
the problem when maven tries compile class (which extends abstractexecutorservice), instead of adding methods android implementation when doesn't find them, continues down classpath, finds java methods , complains return types don't match. ideally don't think java classes should available during android build, since can cause think can run methods can't, can run sorts of java methods not available in android , compile fine (in maven).
does have suggestions or solutions this? run similar?
edit: here relevant part of pom (omitted repositories , such):
<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 , 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 classpath ensure correct jars 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: here compilation error getting.
[error] failed 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 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 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 execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project mystuff: compilation failure
note: executionservice class extends abstractexecutorservice. however, want extend android version , not base java version. tried inserting stub methods of newtaskfor's android version of abstractexecutorservice (in thought compiler should assume overriding methods rather base java ones - although should note there no @override in code) still didn't work.
no 1 asked them here method declarations:
protected <t> future<t> newtaskfor(runnable runnable, t value) { //stuff } protected <t> future<t> newtaskfor(callable<t> callable) { //stuff {
my current theory has template types i'm not sure how go proving or fixing that.
edit 6/30: should note not new code. on year old , has been compiling using ant since then. has been part of numerous stable releases. in process of migrating our build process maven , trying package set build properly.
the problem maven automatically has oracle jdk on classpath , android jar provides alternate implementations of these , differ. @ stage not know if maven compiler plugin can told remove jdk classpath , use dependencies on classpath. imho solve issue.
please create issue in android maven plugin issue tracker , potentially investigate asking on maven user or dev list.
Comments
Post a Comment