Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unpackOutputDirectory and includeNonClassFiles to the unpack goal #779

Merged
merged 2 commits into from
Oct 6, 2018
Merged

Added unpackOutputDirectory and includeNonClassFiles to the unpack goal #779

merged 2 commits into from
Oct 6, 2018

Conversation

lyubomyr-shaydariv
Copy link
Contributor

@lyubomyr-shaydariv lyubomyr-shaydariv commented Sep 25, 2018

This PR adds new two configuration options to make the unpack goal more precise:

  • unpackOutputDirectory to change the originally hardcoded android-classes directory.
  • includeNonClassFilesto allow non-.class files that are not specified in the manifest.

Rationale

Since I have to use Retrolambda, I have to extract v52-bytecode JAR classes from the repository before downgrading the classes bytecode. As of 2018-09-26, I used the following methods described here:

  • Use org.apache.maven.plugins:maven-dependency-plugin to extract non-AAR dependencies.
  • Use org.apache.maven.plugins:maven-antrun-plugin to extract AAR contents because org.apache.maven.plugins:maven-dependency-plugin can't do the job.
  • Use net.orfjackal.retrolambda:retrolambda-maven-plugin to downgrade the bytecode.
  • Use com.simpligility.maven.plugins:android-maven-plugin with the exclusion filter enabled to process downgraded stuff only.

Since the use of org.apache.maven.plugins:maven-dependency-plugin and org.apache.maven.plugins:maven-antrun-plugin is error-prone (concrete groups IDs, artifact IDs and versions should be specified directly in paths), it turns out that the unpack goal from net.orfjackal.retrolambda:retrolambda-maven-plugin can replace the first two plugins. For example,

<plugin>
	<groupId>com.simpligility.maven.plugins</groupId>
	<artifactId>android-maven-plugin</artifactId>
	<executions>
		<execution>
			<phase>process-classes</phase>
			<goals>
				<goal>unpack</goal>
			</goals>
			<!--
			Configuration inherited.
			-->
			<configuration>
				<!--
				unpackOutputDirectory is useful to keep all classes
				in a single directory in order to use the Retrolambda plugin
				that seems to support one input directory only
				-->
				<unpackOutputDirectory>${project.build.directory}/classes</unpackOutputDirectory>
				<!--
				includeNonClassFiles is useful to extract all JAR entries,
				even those that are not included to the META-INF registry.
				For example, the Flyway library Android implementation works
				with the migrations int the assets, but still uses some content
				like version.txt that's provided as a part of the dependency JAR
				as a regular Java resource file.
				-->
				<includeNonClassFiles>true</includeNonClassFiles>
			</configuration>
		</execution>
	</executions>
	<configuration>
		<!--
		We specified the source entries to extract previously.
		-->
		<skipDependencies>true</skipDependencies>
	</configuration>
</plugin>

<plugin>
	<groupId>net.orfjackal.retrolambda</groupId>
	<artifactId>retrolambda-maven-plugin</artifactId>
	<executions>
		<execution>
			<phase>process-classes</phase>
			<goals>
				<goal>process-main</goal>
			</goals>
		</execution>
	</executions>
</plugin>

<!--
This step is not even necessary now -- it's default and does not require additional configuration.
Please note that the configuration section with the exclusion can be omitted as well.
<plugin>
	<groupId>com.simpligility.maven.plugins</groupId>
	<artifactId>android-maven-plugin</artifactId>
</plugin>
-->

@lyubomyr-shaydariv lyubomyr-shaydariv changed the title Unpack.unpack output directory Added unpackOutputDirectory and includeNonClassFiles to the unpack goal Sep 25, 2018
@william-ferguson-au william-ferguson-au merged commit d0cee8b into simpligility:master Oct 6, 2018
@lyubomyr-shaydariv lyubomyr-shaydariv deleted the unpack.unpackOutputDirectory branch October 8, 2018 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants