Skip to content

Commit 38bb0fc

Browse files
committed
remove conflicting maven dependencies in plugin pom
1 parent 57890ba commit 38bb0fc

File tree

10 files changed

+174
-111
lines changed

10 files changed

+174
-111
lines changed

README.md

+61-6
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55

66
Library for packing and unpacking Chrome extension `.crx` files.
77

8-
## Maven
8+
## Core Library
9+
10+
### Maven Dependency Info
911

1012
<dependency>
1113
<groupId>com.github.mike10004</groupId>
12-
<artifactId>crxtool</artifactId>
13-
<version>0.3</version>
14+
<artifactId>crxtool-core</artifactId>
15+
<version>0.5</version>
1416
</dependency>
1517

16-
## Usage
18+
### Usage
1719

18-
### Unpacking
20+
#### Unpacking
1921

2022
try (InputStream in = new FileInputStream("my_extension.crx") {
2123
CrxMetadata metadata = CrxParser.getDefault().parseMetadata(in);
@@ -25,7 +27,7 @@ Library for packing and unpacking Chrome extension `.crx` files.
2527
// ...
2628
}
2729

28-
### Packing
30+
#### Packing
2931

3032
Path extensionDir = new File("manifest-parent-dir").toPath();
3133
java.security.KeyPairGenerator keyGen = java.security.KeyPairGenerator.getInstance("RSA");
@@ -36,6 +38,59 @@ Library for packing and unpacking Chrome extension `.crx` files.
3638
CrxPacker.getDefault().packExtension(extensionDir, keyPair, out);
3739
}
3840

41+
## Maven Plugin
42+
43+
### Maven Dependency Info
44+
45+
<dependency>
46+
<groupId>com.github.mike10004</groupId>
47+
<artifactId>crxtool-maven-plugin</artifactId>
48+
<version>0.5</version>
49+
</dependency>
50+
51+
### Usage
52+
53+
Place extension source files in `src/main/extension`.
54+
55+
<build>
56+
<plugins>
57+
<plugin>
58+
<groupId>com.github.mike10004</groupId>
59+
<artifactId>crxtool-maven-plugin</artifactId>
60+
<version>0.5</version>
61+
<executions>
62+
<execution>
63+
<id>pack</id>
64+
<goals>
65+
<goal>pack-extension</goal>
66+
</goals>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
<plugin>
71+
<groupId>org.codehaus.mojo</groupId>
72+
<artifactId>build-helper-maven-plugin</artifactId>
73+
<version>3.0.0</version>
74+
<executions>
75+
<execution>
76+
<id>attach-artifact</id>
77+
<goals>
78+
<goal>attach-artifact</goal>
79+
</goals>
80+
<configuration>
81+
<artifacts>
82+
<artifact>
83+
<file>${project.build.directory}/${project.artifactId}-${project.version}.crx</file>
84+
<type>crx</type>
85+
</artifact>
86+
</artifacts>
87+
</configuration>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
</plugins>
92+
</build>
93+
3994
## Credits
4095

4196
The extension ID construction is probably from [this Stack Overflow answer](https://stackoverflow.com/a/2050916/2657036).

crxtool-core/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<modelVersion>4.0.0</modelVersion>
66
<parent>
77
<groupId>com.github.mike10004</groupId>
8-
<artifactId>crxtool-parent</artifactId>
9-
<version>0.4</version>
8+
<artifactId>crxtool</artifactId>
9+
<version>0.5-SNAPSHOT</version>
1010
</parent>
1111
<artifactId>crxtool-core</artifactId>
1212
<name>crxtool-core</name>

crxtool-maven-plugin-example/pom.xml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>com.github.mike10004</groupId>
7+
<artifactId>crxtool</artifactId>
8+
<version>0.5-SNAPSHOT</version>
9+
</parent>
10+
<artifactId>crxtool-maven-plugin-example</artifactId>
11+
<packaging>pom</packaging>
12+
<modelVersion>4.0.0</modelVersion>
13+
14+
<build>
15+
<plugins>
16+
<plugin>
17+
<groupId>com.github.mike10004</groupId>
18+
<artifactId>crxtool-maven-plugin</artifactId>
19+
<version>${project.version}</version>
20+
<executions>
21+
<execution>
22+
<id>pack</id>
23+
<goals>
24+
<goal>pack-extension</goal>
25+
</goals>
26+
</execution>
27+
</executions>
28+
</plugin>
29+
<plugin>
30+
<groupId>org.codehaus.mojo</groupId>
31+
<artifactId>build-helper-maven-plugin</artifactId>
32+
<version>3.0.0</version>
33+
<executions>
34+
<execution>
35+
<id>attach-artifact</id>
36+
<goals>
37+
<goal>attach-artifact</goal>
38+
</goals>
39+
<configuration>
40+
<artifacts>
41+
<artifact>
42+
<file>${project.build.directory}/${project.artifactId}-${project.version}.crx</file>
43+
<type>crx</type>
44+
</artifact>
45+
</artifacts>
46+
</configuration>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
<plugin>
51+
<artifactId>maven-jar-plugin</artifactId>
52+
<version>2.4</version>
53+
<executions>
54+
<execution>
55+
<id>default-jar</id>
56+
<phase>never</phase>
57+
</execution>
58+
</executions>
59+
</plugin>
60+
</plugins>
61+
</build>
62+
63+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Called when the user clicks on the browser action.
6+
chrome.browserAction.onClicked.addListener(function(tab) {
7+
// No tabs or host permissions needed!
8+
console.log('Turning ' + tab.url + ' red!');
9+
chrome.tabs.executeScript({
10+
code: 'document.body.style.backgroundColor="red"'
11+
});
12+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "Page Redder",
3+
"description": "Make the current page red",
4+
"version": "2.0",
5+
"permissions": [
6+
"activeTab"
7+
],
8+
"background": {
9+
"scripts": ["background.js"],
10+
"persistent": false
11+
},
12+
"browser_action": {
13+
"default_title": "Make this page red"
14+
},
15+
"manifest_version": 2
16+
}

crxtool-maven-plugin/pom.xml

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<parent>
4-
<artifactId>crxtool-parent</artifactId>
4+
<artifactId>crxtool</artifactId>
55
<groupId>com.github.mike10004</groupId>
6-
<version>0.4</version>
6+
<version>0.5-SNAPSHOT</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>crxtool-maven-plugin</artifactId>
@@ -26,16 +26,6 @@
2626
<artifactId>maven-plugin-api</artifactId>
2727
<version>3.5.2</version>
2828
</dependency>
29-
<dependency>
30-
<groupId>org.apache.maven</groupId>
31-
<artifactId>maven-project</artifactId>
32-
<version>2.2.1</version>
33-
</dependency>
34-
<dependency>
35-
<groupId>org.apache.maven</groupId>
36-
<artifactId>maven-core</artifactId>
37-
<version>3.5.2</version>
38-
</dependency>
3929
<dependency>
4030
<groupId>junit</groupId>
4131
<artifactId>junit</artifactId>
@@ -55,7 +45,7 @@
5545
<dependency>
5646
<groupId>com.github.mike10004</groupId>
5747
<artifactId>crxtool-testing</artifactId>
58-
<version>0.4</version>
48+
<version>0.5-SNAPSHOT</version>
5949
<scope>test</scope>
6050
</dependency>
6151
</dependencies>

crxtool-maven-plugin/src/main/java/com/github/mike10004/crxtool/maven/PackExtensionMojo.java

+2-25
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
import io.github.mike10004.crxtool.CrxPacker;
44
import io.github.mike10004.crxtool.KeyPairs;
55
import io.github.mike10004.crxtool.Zipping;
6-
import org.apache.maven.execution.MavenSession;
76
import org.apache.maven.plugin.AbstractMojo;
87
import org.apache.maven.plugin.MojoExecutionException;
98
import org.apache.maven.plugins.annotations.LifecyclePhase;
109
import org.apache.maven.plugins.annotations.Mojo;
1110
import org.apache.maven.plugins.annotations.Parameter;
12-
import org.apache.maven.project.MavenProject;
1311

1412
import java.io.File;
1513
import java.io.FileInputStream;
@@ -35,12 +33,6 @@ public class PackExtensionMojo extends AbstractMojo {
3533

3634
public static final String PROP_PREFIX = "crxtool.";
3735

38-
@Parameter( defaultValue = "${session}", readonly = true )
39-
private MavenSession session;
40-
41-
@Parameter( defaultValue = "${project}", readonly = true )
42-
private MavenProject project;
43-
4436
/**
4537
* Directory that contains extension source code and resource files. This
4638
* is the parent directory of {@code manifest.json}.
@@ -59,7 +51,7 @@ public class PackExtensionMojo extends AbstractMojo {
5951
* that is to be produced. If you set {@link #excludeHeader} to true, this
6052
* should be changed to a zip file.
6153
*/
62-
@Parameter(defaultValue = "${project.build.directory}/${project.name}.crx")
54+
@Parameter(defaultValue = "${project.build.directory}/${project.artifactId}-${project.version}.crx")
6355
private File outputFile;
6456

6557
/**
@@ -84,6 +76,7 @@ public void execute() throws MojoExecutionException {
8476
keyPair = KeyPairs.generateRsKeyPair(createRandom());
8577
}
8678
Path extensionDir = sourceDirectory.toPath();
79+
com.google.common.io.Files.createParentDirs(outputFile);
8780
if (isExcludeHeader()) {
8881
byte[] zipBytes = Zipping.zipDirectory(extensionDir, null);
8982
java.nio.file.Files.write(outputFile.toPath(), zipBytes);
@@ -107,14 +100,6 @@ protected SecureRandom createRandom() {
107100
return new SecureRandom();
108101
}
109102

110-
public MavenSession getSession() {
111-
return session;
112-
}
113-
114-
public MavenProject getProject() {
115-
return project;
116-
}
117-
118103
public File getSourceDirectory() {
119104
return sourceDirectory;
120105
}
@@ -131,14 +116,6 @@ public boolean isExcludeHeader() {
131116
return excludeHeader;
132117
}
133118

134-
void setSession(MavenSession session) {
135-
this.session = session;
136-
}
137-
138-
void setProject(MavenProject project) {
139-
this.project = project;
140-
}
141-
142119
public void setSourceDirectory(File sourceDirectory) {
143120
this.sourceDirectory = sourceDirectory;
144121
}

0 commit comments

Comments
 (0)