20
20
* Represents <a href="http://lesscss.org/usage/index.html#command-line-usage-options">Less compiler options</a>
21
21
* responsible for controlling the {@link LessCompiler} compilation process.
22
22
* @since 2.0.0
23
- * @see LessCompilerOptionsBuilder
23
+ * @see LessOptionsBuilder
24
24
*/
25
- public class LessCompilerOptions {
25
+ public class LessOptions {
26
26
27
27
private boolean silent ;
28
28
private boolean strictImports ;
@@ -36,11 +36,16 @@ public class LessCompilerOptions {
36
36
private boolean strictMath ;
37
37
private boolean strictUnits ;
38
38
39
+ private String sourceMapRootPath ;
40
+ private String sourceMapBasePath ;
41
+ private boolean sourceMapLessInline ;
42
+ private String sourceMapUrl ;
43
+
39
44
/**
40
45
* Constructs a new instance.
41
46
* @since 2.0.0
42
47
*/
43
- public LessCompilerOptions () {
48
+ public LessOptions () {
44
49
ieCompatibility = true ;
45
50
javaScript = true ;
46
51
includePaths = Collections .emptyList ();
@@ -50,10 +55,10 @@ public LessCompilerOptions() {
50
55
/**
51
56
* Constructs a new instance as a copy of an another options object.
52
57
* @param options the another options object (cannot be {@code null}).
53
- * @throws IllegalArgumentException if options is equal to {@code null}.
58
+ * @throws IllegalArgumentException if options is {@code null}.
54
59
* @since 2.0.0
55
60
*/
56
- public LessCompilerOptions (final LessCompilerOptions options ) {
61
+ public LessOptions (final LessOptions options ) {
57
62
if (options == null ) {
58
63
throw new IllegalArgumentException ("Options cannot be null" );
59
64
}
@@ -68,6 +73,11 @@ public LessCompilerOptions(final LessCompilerOptions options) {
68
73
relativeUrls = options .relativeUrls ;
69
74
strictMath = options .strictMath ;
70
75
strictUnits = options .strictUnits ;
76
+
77
+ sourceMapRootPath = options .sourceMapRootPath ;
78
+ sourceMapBasePath = options .sourceMapBasePath ;
79
+ sourceMapLessInline = options .sourceMapLessInline ;
80
+ sourceMapUrl = options .sourceMapUrl ;
71
81
}
72
82
73
83
/**
@@ -134,7 +144,7 @@ public void setCompress(final boolean compress) {
134
144
* @return {@code true} whether the CSS code should be compatible with IE browser, otherwise {@code false}.
135
145
* @since 2.0.0
136
146
*/
137
- public boolean isIeCompatability () {
147
+ public boolean isIeCompatibility () {
138
148
return ieCompatibility ;
139
149
}
140
150
@@ -169,9 +179,10 @@ public void setJavaScript(final boolean javaScript) {
169
179
}
170
180
171
181
/**
172
- * Returns available include paths (default: empty collection). If the file in an @import rule does not exist at
173
- * that exact location, a compiler will look for it at the location(s) passed to this option. You might use this for
174
- * instance to specify a path to a library which you want to be referenced simply and relatively in the less files.
182
+ * Returns available include paths (default: {@code empty collection}). If the file in an @import rule does not
183
+ * exist at that exact location, a compiler will look for it at the location(s) passed to this option. You might use
184
+ * this for instance to specify a path to a library which you want to be referenced simply and relatively in the
185
+ * less files.
175
186
* @return the available include paths (never {@code null}).
176
187
* @since 2.0.0
177
188
*/
@@ -180,10 +191,11 @@ public List<String> getIncludePaths() {
180
191
}
181
192
182
193
/**
183
- * Sets available include paths (default: empty collection). If the file in an @import rule does not exist at
184
- * that exact location, a compiler will look for it at the location(s) passed to this option. You might use this for
185
- * instance to specify a path to a library which you want to be referenced simply and relatively in the less files.
186
- * @param includePaths the available include paths ({@code null} is treated as empty collection).
194
+ * Sets available include paths (default: {@code empty collection}). If the file in an @import rule does not
195
+ * exist at that exact location, a compiler will look for it at the location(s) passed to this option. You might use
196
+ * this for instance to specify a path to a library which you want to be referenced simply and relatively in the
197
+ * less files.
198
+ * @param includePaths the available include paths ({@code null} is treated as an empty collection).
187
199
* @since 2.0.0
188
200
*/
189
201
public void setIncludePaths (final List <String > includePaths ) {
@@ -372,6 +384,7 @@ public void setRelativeUrls(final boolean relativeUrls) {
372
384
* @return {@code true} whether the compiler should try and process all maths in the Less code, otherwise
373
385
* {@code false}.
374
386
* @since 2.0.0
387
+ * @see #isStrictUnits()
375
388
*/
376
389
public boolean isStrictMath () {
377
390
return strictMath ;
@@ -415,6 +428,7 @@ public boolean isStrictMath() {
415
428
* @param strictMath {@code true} whether the compiler should try and process all maths in the Less code, otherwise
416
429
* {@code false}.
417
430
* @since 2.0.0
431
+ * @see #setStrictUnits(boolean)
418
432
*/
419
433
public void setStrictMath (final boolean strictMath ) {
420
434
this .strictMath = strictMath ;
@@ -438,6 +452,7 @@ public void setStrictMath(final boolean strictMath) {
438
452
* @return {@code true} whether the compiler should guess units in the Less code when it does maths, otherwise
439
453
* {@code false}.
440
454
* @since 2.0.0
455
+ * @see #isStrictMath()
441
456
*/
442
457
public boolean isStrictUnits () {
443
458
return strictUnits ;
@@ -461,52 +476,159 @@ public boolean isStrictUnits() {
461
476
* @param strictUnits {@code true} whether the compiler should guess units in the Less code when it does maths,
462
477
* otherwise {@code false}.
463
478
* @since 2.0.0
479
+ * @see #setStrictMath(boolean)
464
480
*/
465
481
public void setStrictUnits (final boolean strictUnits ) {
466
482
this .strictUnits = strictUnits ;
467
483
}
468
484
469
485
/**
470
- * Available values of the {@code line numbers} option.
486
+ * Returns a path that will be prepended to each of the Less file paths inside the Source Map and also to the path
487
+ * to the map file specified in your output CSS.
488
+ * <p>
489
+ * Use it if for instance you have a CSS file generated in the root on your web server but have your source
490
+ * less/css/map files in a different folder.
491
+ * </p>
492
+ * <p>
493
+ * Example: if you have a follow file structure:
494
+ * </p>
495
+ *
496
+ * <pre>
497
+ * output.css
498
+ * dev-files/output.css.map
499
+ * dev-files/output.less
500
+ * </pre>
501
+ * <p>
502
+ * then you should set the Source Map root path to {@code dev-files/}.
503
+ * </p>
504
+ * <p>
505
+ * This option is the opposite of the {@link #getSourceMapBasePath() Source Map base path} option.
506
+ * </p>
507
+ * @return the path which will be added.
471
508
* @since 2.0.0
472
- * @see LessCompilerOptions#setLineNumbers(LineNumbersValue)
509
+ * @see #getSourceMapBasePath()
510
+ * @see #getSourceMapUrl()
473
511
*/
474
- public enum LineNumbersValue {
512
+ public String getSourceMapRootPath () {
513
+ return sourceMapRootPath ;
514
+ }
475
515
476
- /**
477
- * Line numbers won't be put in CSS code.
478
- * @since 2.0.0
479
- */
480
- OFF ("" ),
481
- /**
482
- * Line numbers will be put in CSS comments blocks.
483
- * @since 2.0.0
484
- */
485
- COMMENTS ("comments" ),
486
- /**
487
- * Line numbers will be put in @media queries.
488
- * @since 2.0.0
489
- */
490
- MEDIA_QUERY ("mediaquery" ),
491
- /**
492
- * Line numbers will be put in CSS comments blocks and @media queries.
493
- * @since 2.0.0
494
- */
495
- ALL ("all" );
516
+ /**
517
+ * Sets a path that will be prepended to each of the Less file paths inside the Source Map and also to the path to
518
+ * the map file specified in your output CSS (default: {@code null}).
519
+ * <p>
520
+ * Use it if for instance you have a CSS file generated in the root on your web server but have your source
521
+ * less/css/map files in a different folder.
522
+ * </p>
523
+ * <p>
524
+ * Example: if you have a follow file structure:
525
+ * </p>
526
+ *
527
+ * <pre>
528
+ * output.css
529
+ * dev-files/output.css.map
530
+ * dev-files/output.less
531
+ * </pre>
532
+ * <p>
533
+ * then you should set the Source Map root path to {@code dev-files/}.
534
+ * </p>
535
+ * <p>
536
+ * This option is the opposite of the {@link #setSourceMapBasePath(String) Source Map base path} option.
537
+ * </p>
538
+ * @param sourceMapRootPath the path which will be added.
539
+ * @since 2.0.0
540
+ * @see #setSourceMapBasePath(String)
541
+ * @see #setSourceMapUrl(String)
542
+ */
543
+ public void setSourceMapRootPath (final String sourceMapRootPath ) {
544
+ this .sourceMapRootPath = sourceMapRootPath ;
545
+ }
496
546
497
- private final String value ;
547
+ /**
548
+ * Returns a path that will be removed from each of the Less file paths inside the Source Map and also from the path
549
+ * to the map file specified in your output CSS (default: {@code null}).
550
+ * <p>
551
+ * It specifies a path which should be removed from the output paths. For instance if you are compiling a file in
552
+ * the less-files directory but the source files will be available on your web server in the root or current
553
+ * directory, you can specify this to remove the additional less-files part of the path.
554
+ * </p>
555
+ * <p>
556
+ * This option is the opposite of the {@link #getSourceMapRootPath() Source Map root path} option.
557
+ * </p>
558
+ * @return the path which will be removed.
559
+ * @since 2.0.0
560
+ * @see #getSourceMapRootPath()
561
+ * @see #getSourceMapUrl()
562
+ */
563
+ public String getSourceMapBasePath () {
564
+ return sourceMapBasePath ;
565
+ }
498
566
499
- LineNumbersValue (final String value ) {
500
- this .value = value ;
501
- }
567
+ /**
568
+ * Sets a path that will be removed from each of the Less file paths inside the Source Map and also from the path to
569
+ * the map file specified in your output CSS (default: {@code null}).
570
+ * <p>
571
+ * It specifies a path which should be removed from the output paths. For instance if you are compiling a file in
572
+ * the less-files directory but the source files will be available on your web server in the root or current
573
+ * directory, you can specify this to remove the additional less-files part of the path.
574
+ * </p>
575
+ * <p>
576
+ * This option is the opposite of the {@link #setSourceMapRootPath(String) Source Map root path} option.
577
+ * </p>
578
+ * @param sourceMapBasePath the path which will be removed.
579
+ * @since 2.0.0
580
+ * @see #setSourceMapRootPath(String)
581
+ * @see #setSourceMapUrl(String)
582
+ */
583
+ public void setSourceMapBasePath (final String sourceMapBasePath ) {
584
+ this .sourceMapBasePath = sourceMapBasePath ;
585
+ }
502
586
503
- /**
504
- * Returns a value assigned to {@code this} object.
505
- * @return the value assigned to {@code this} object.
506
- * @since 2.0.0
507
- */
508
- public String getValue () {
509
- return value ;
510
- }
587
+ /**
588
+ * Checks whether a compiler should include all of the Less files in to the Source Map (default: {@code false}).
589
+ * This means that you only need your map file to get to your original source.
590
+ * @return {@code true} whether the compiler should include all of the Less files in to the Source Map, otherwise
591
+ * {@code false}.
592
+ * @since 2.0.0
593
+ */
594
+ public boolean isSourceMapLessInline () {
595
+ return sourceMapLessInline ;
596
+ }
597
+
598
+ /**
599
+ * Sets whether a compiler should include all of the Less files in to the Source Map (default: {@code false}). This
600
+ * means that you only need your map file to get to your original source.
601
+ * @param sourceMapLessInline {@code true} whether the compiler should include all of the Less files in to the
602
+ * Source Map, otherwise {@code false}.
603
+ * @since 2.0.0
604
+ */
605
+ public void setSourceMapLessInline (final boolean sourceMapLessInline ) {
606
+ this .sourceMapLessInline = sourceMapLessInline ;
607
+ }
608
+
609
+ /**
610
+ * Returns a path which will overwrite the URL in the CSS that points at the Source Map map file (default:
611
+ * {@code null}). This is for cases when the {@link #getSourceMapRootPath() root path} and the
612
+ * {@link #getSourceMapBasePath() base path} options are not producing exactly what you need.
613
+ * @return the Source Map URL.
614
+ * @since 2.0.0
615
+ * @see #getSourceMapBasePath()
616
+ * @see #getSourceMapRootPath()
617
+ */
618
+ public String getSourceMapUrl () {
619
+ return sourceMapUrl ;
620
+ }
621
+
622
+ /**
623
+ * Sets a path which will overwrite the URL in the CSS that points at the Source Map map file (default:
624
+ * {@code null}). This is for cases when the {@link #setSourceMapRootPath(String) root path} and the
625
+ * {@link #setSourceMapBasePath(String) base path} options are not producing exactly what you need.
626
+ * @param sourceMapUrl the Source Map URL.
627
+ * @since 2.0.0
628
+ * @see #setSourceMapBasePath(String)
629
+ * @see #setSourceMapRootPath(String)
630
+ */
631
+ public void setSourceMapUrl (final String sourceMapUrl ) {
632
+ this .sourceMapUrl = sourceMapUrl ;
511
633
}
512
634
}
0 commit comments