Skip to content

Commit 921dad3

Browse files
committed
Adds license headers to files in templates folder.
Also, updates code that uses the template files when building plugins to strip the license (since we don't want to add it to users' projects).
1 parent 6600712 commit 921dad3

File tree

8 files changed

+131
-8
lines changed

8 files changed

+131
-8
lines changed

cordova-lib/src/plugman/create.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ var Q = require('q'),
2222
path = require('path'),
2323
shell = require('shelljs'),
2424
et = require('elementtree'),
25-
CordovaError = require('../CordovaError');
25+
CordovaError = require('../CordovaError'),
26+
stripLicense = require('./util/strip-license');
27+
2628

2729
module.exports = function create( name, id, version, pluginPath, options ) {
2830
var cwd = pluginPath + '/' + name + '/',
@@ -62,7 +64,7 @@ module.exports = function create( name, id, version, pluginPath, options ) {
6264
shell.mkdir( '-p', cwd + 'src' );
6365

6466
// Create a base plugin.js file
65-
baseJS = fs.readFileSync( templatesDir + 'base.js', 'utf-8').replace( /%pluginName%/g, name );
67+
baseJS = stripLicense.fromCode(fs.readFileSync(templatesDir + 'base.js', 'utf-8').replace(/%pluginName%/g, name));
6668
fs.writeFileSync( cwd + 'www/' + name + '.js', baseJS, 'utf-8' );
6769
// Add it to the xml as a js module
6870
jsMod = et.Element( 'js-module' );

cordova-lib/src/plugman/platform.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ var Q = require('q'),
2323
et = require('elementtree'),
2424
fs = require('fs'),
2525
shell = require('shelljs'),
26-
path = require('path');
26+
path = require('path'),
27+
stripLicense = require('./util/strip-license');
2728

2829
/**
2930
* Used for adding templates for plugin platforms to plugin.xml
@@ -115,9 +116,9 @@ function doPlatformBase( templatesDir, platformName, pluginName, pluginID, plugi
115116
case 'android':
116117
baseFiles.push (
117118
{
118-
file: fs.readFileSync( templatesDir + "base.java", "utf-8" )
119-
.replace( /%pluginName%/g, pluginName )
120-
.replace( /%pluginID%/g, pluginID ),
119+
file: stripLicense.fromCode(fs.readFileSync(templatesDir + "base.java", "utf-8")
120+
.replace(/%pluginName%/g, pluginName)
121+
.replace(/%pluginID%/g, pluginID)),
121122
extension: "java"
122123
}
123124
);
@@ -126,8 +127,8 @@ function doPlatformBase( templatesDir, platformName, pluginName, pluginID, plugi
126127
case 'ios':
127128
baseFiles.push(
128129
{
129-
file: fs.readFileSync( templatesDir + "base.m", "utf-8" )
130-
.replace( /%pluginName%/g, pluginName ),
130+
file: stripLicense.fromCode(fs.readFileSync(templatesDir + "base.m", "utf-8")
131+
.replace(/%pluginName%/g, pluginName)),
131132
extension: "m"
132133
}
133134
);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
module.exports = {
21+
fromCode: function (code) {
22+
// For simplicity, relies on the fact that the Apache license header doesn't contain a "*"
23+
return code.replace(/^\s*\/\*\*[^\*]*\*\/\s*/, "");
24+
}
25+
};

cordova-lib/templates/base.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/**
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
120
var exec = require('cordova/exec');
221

322
exports.coolMethod = function(arg0, success, error) {

cordova-lib/templates/platforms/android/android.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
<platform name="android">
221
<config-file target="res/xml/config.xml" parent="/*">
322
<feature name="%pluginName%">

cordova-lib/templates/platforms/android/base.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/**
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
120
package %pluginID%;
221

322
import org.apache.cordova.CordovaPlugin;

cordova-lib/templates/platforms/ios/base.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/**
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
120
/********* %pluginName%.m Cordova Plugin Implementation *******/
221

322
#import <Cordova/CDV.h>

cordova-lib/templates/platforms/ios/ios.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
<platform name="ios">
221
<config-file target="config.xml" parent="/*">
322
<feature name="%pluginName%">

0 commit comments

Comments
 (0)